diff --git a/Cargo.lock b/Cargo.lock index e5df61d61ce..5716ee2fc14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,7 +72,14 @@ name = "annotate-snippets" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d78ea013094e5ea606b1c05fe35f1dd7ea1eb1ea259908d040b25bd5ec677ee5" + +[[package]] +name = "annotate-snippets" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3b9d411ecbaf79885c6df4d75fff75858d5995ff25385657a28af47e82f9c36" dependencies = [ + "unicode-width", "yansi-term", ] @@ -614,6 +621,7 @@ checksum = "6d76c22c9b9b215eeb8d016ad3a90417bd13cb24cf8142756e6472445876cab7" dependencies = [ "atty", "bitflags", + "clap_derive", "indexmap", "lazy_static", "os_str_bytes", @@ -631,6 +639,19 @@ dependencies = [ "clap 3.1.1", ] +[[package]] +name = "clap_derive" +version = "3.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c" +dependencies = [ + "heck 0.4.0", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "clippy" version = "0.1.63" @@ -1099,11 +1120,10 @@ dependencies = [ [[package]] name = "dirs" -version = "2.0.2" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ - "cfg-if 0.1.10", "dirs-sys", ] @@ -1219,19 +1239,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "env_logger" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" -dependencies = [ - "atty", - "humantime 2.0.1", - "log", - "regex", - "termcolor", -] - [[package]] name = "env_logger" version = "0.9.0" @@ -1708,6 +1715,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -3290,7 +3303,7 @@ dependencies = [ "difference", "env_logger 0.9.0", "futures 0.3.19", - "heck", + "heck 0.3.1", "home", "itertools", "jsonrpc-core", @@ -3500,6 +3513,7 @@ version = "1.0.0" dependencies = [ "bstr", "byteorder", + "clap 3.1.1", "crossbeam-utils", "libc", "libz-sys", @@ -3834,7 +3848,7 @@ dependencies = [ name = "rustc_errors" version = "0.0.0" dependencies = [ - "annotate-snippets", + "annotate-snippets 0.8.0", "atty", "rustc_data_structures", "rustc_error_messages", @@ -4085,7 +4099,7 @@ dependencies = [ name = "rustc_macros" version = "0.1.0" dependencies = [ - "annotate-snippets", + "annotate-snippets 0.8.0", "fluent-bundle", "fluent-syntax", "proc-macro2", @@ -4687,16 +4701,17 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "1.4.38" +version = "1.5.0" dependencies = [ - "annotate-snippets", + "annotate-snippets 0.9.1", "anyhow", "bytecount", "cargo_metadata", + "clap 3.1.1", "derive-new", "diff", "dirs", - "env_logger 0.8.4", + "env_logger 0.9.0", "getopts", "ignore", "itertools", @@ -4707,8 +4722,7 @@ dependencies = [ "rustfmt-config_proc_macro", "serde", "serde_json", - "structopt", - "term 0.6.1", + "term", "thiserror", "toml", "unicode-segmentation", @@ -5096,30 +5110,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "structopt" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c" -dependencies = [ - "clap 2.34.0", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "strum" version = "0.18.0" @@ -5132,7 +5122,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c" dependencies = [ - "heck", + "heck 0.3.1", "proc-macro2", "quote", "syn", @@ -5212,16 +5202,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "term" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" -dependencies = [ - "dirs", - "winapi", -] - [[package]] name = "term" version = "0.7.0" @@ -5276,7 +5256,7 @@ dependencies = [ "getopts", "libc", "num_cpus", - "term 0.7.0", + "term", ] [[package]] @@ -5705,9 +5685,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" [[package]] name = "unicode-width" diff --git a/src/tools/rustc-workspace-hack/Cargo.toml b/src/tools/rustc-workspace-hack/Cargo.toml index a79290e7a6b..992a2e83f63 100644 --- a/src/tools/rustc-workspace-hack/Cargo.toml +++ b/src/tools/rustc-workspace-hack/Cargo.toml @@ -73,6 +73,7 @@ features = [ [dependencies] bstr = { version = "0.2.13", features = ["default"] } byteorder = { version = "1", features = ['default', 'std'] } +clap = { version = "3.1.1", features = ["lazy_static", "derive", "clap_derive"]} curl-sys = { version = "0.4.13", features = ["http2", "libnghttp2-sys"], optional = true } crossbeam-utils = { version = "0.8.0", features = ["nightly"] } libc = { version = "0.2.79", features = ["align"] } diff --git a/src/tools/rustfmt/.github/workflows/integration.yml b/src/tools/rustfmt/.github/workflows/integration.yml index b79221d0543..4d8899b434b 100644 --- a/src/tools/rustfmt/.github/workflows/integration.yml +++ b/src/tools/rustfmt/.github/workflows/integration.yml @@ -69,7 +69,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Run build - name: install rustup diff --git a/src/tools/rustfmt/.github/workflows/linux.yml b/src/tools/rustfmt/.github/workflows/linux.yml index 45f63b83c05..6a3f9d89d98 100644 --- a/src/tools/rustfmt/.github/workflows/linux.yml +++ b/src/tools/rustfmt/.github/workflows/linux.yml @@ -26,7 +26,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Run build - name: install rustup diff --git a/src/tools/rustfmt/.github/workflows/mac.yml b/src/tools/rustfmt/.github/workflows/mac.yml index 55e1cc9539b..7dfda3142ca 100644 --- a/src/tools/rustfmt/.github/workflows/mac.yml +++ b/src/tools/rustfmt/.github/workflows/mac.yml @@ -23,7 +23,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Run build - name: install rustup diff --git a/src/tools/rustfmt/.github/workflows/rustdoc_check.yml b/src/tools/rustfmt/.github/workflows/rustdoc_check.yml index ca96d30f586..cd0c3218971 100644 --- a/src/tools/rustfmt/.github/workflows/rustdoc_check.yml +++ b/src/tools/rustfmt/.github/workflows/rustdoc_check.yml @@ -11,7 +11,7 @@ jobs: name: rustdoc check steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: install rustup run: | diff --git a/src/tools/rustfmt/.github/workflows/upload-assets.yml b/src/tools/rustfmt/.github/workflows/upload-assets.yml index f4dd3944453..25699234a1e 100644 --- a/src/tools/rustfmt/.github/workflows/upload-assets.yml +++ b/src/tools/rustfmt/.github/workflows/upload-assets.yml @@ -31,7 +31,7 @@ jobs: target: x86_64-pc-windows-msvc runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # Run build - name: install rustup diff --git a/src/tools/rustfmt/.github/workflows/windows.yml b/src/tools/rustfmt/.github/workflows/windows.yml index dcb08b5412e..4ebc2963849 100644 --- a/src/tools/rustfmt/.github/workflows/windows.yml +++ b/src/tools/rustfmt/.github/workflows/windows.yml @@ -33,7 +33,7 @@ jobs: - name: disable git eol translation run: git config --global core.autocrlf false - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Run build - name: Install Rustup using win.rustup.rs diff --git a/src/tools/rustfmt/CHANGELOG.md b/src/tools/rustfmt/CHANGELOG.md index 5b233608583..bfc155cd656 100644 --- a/src/tools/rustfmt/CHANGELOG.md +++ b/src/tools/rustfmt/CHANGELOG.md @@ -2,9 +2,82 @@ ## [Unreleased] +## [1.5.0] 2022-06-13 + +### Changed + +- Simplify the rustfmt help text by eliding the full path to the rustfmt binary path from the usage string when running `rustfmt --help` [#5214](https://github.com/rust-lang/rustfmt/issues/5214) + ### Fixed -- Fixes issue where wrapped strings would be incorrectly indented in macro defs when `format_strings` was enabled [#4036](https://github.com/rust-lang/rustfmt/issues/4036) +- Remove duplicate imports when `imports_granularity` is set to `Item` [#4725](https://github.com/rust-lang/rustfmt/issues/4725) +- Properly handle stdin input containing an inner skip attribute [#5368](https://github.com/rust-lang/rustfmt/issues/5368) +- Maintain attributes on imports when `imports_granularity` is set to `Item` [#5030](https://github.com/rust-lang/rustfmt/issues/5030) +- Format empty trait definitions as a single line when both `empty_item_single_line` is enabled and `brace_style` is set to `AlwaysNextLine` [#5047](https://github.com/rust-lang/rustfmt/issues/5047) +- Don't change granularity of imports containing comments with `imports_granularity` if doing so could lose or misplace those comments [#5311](https://github.com/rust-lang/rustfmt/pull/5311) +- Prevent rustfmt from removing trailing comments at the end of files annotated with inner `#![rustfmt::skip]` attributes [#5033](https://github.com/rust-lang/rustfmt/issues/5033) +- Fixed various `error[internal]: left behind trailing whitespace"` issues: + - Remove trailing whitespace when formatting a where clause who's bounds have an empty right hand side [#5012](https://github.com/rust-lang/rustfmt/issues/5012) [#4850](https://github.com/rust-lang/rustfmt/issues/4850) + - Prevent rustfmt from adding an empty comment line when rewriting markdown lists at the start of doc comments. This issue was triggered when `wrap_comments=true` [#5088](https://github.com/rust-lang/rustfmt/issues/5088) +- Prevent adding a block indented newline before a function parameter with a complex type that was formatted over multiple lines [#5125](https://github.com/rust-lang/rustfmt/issues/5125) +- Fix various module resolution issues preventing rustfmt from finding modules that should be formatted: + - Handle external mods imported via external->inline load hierarchy [#5063](https://github.com/rust-lang/rustfmt/issues/5063) + - Resolve sub modules of integration tests [#5119](https://github.com/rust-lang/rustfmt/issues/5119) + - Module resolution will fallback to the current search directory if a relative directory search results in a `FileNotFound` error [#5198](https://github.com/rust-lang/rustfmt/issues/5198) +- Give users a clearer error message when resolving a module who's file path is ambiguous (e.g `x.rs` and `x/mod.rs`). Before users were given a `File not found` error message which was confusing [#5167](https://github.com/rust-lang/rustfmt/issues/5167) +- Fix various issues related to type aliases: + - Prevent rustfmt from adding `= impl` to associated types defined in macro bodies [#4823](https://github.com/rust-lang/rustfmt/issues/4823) + - Properly block indent type alias impl traits (TAITs) that wrap to the next line when `version=Two` is set. Before any trait bounds that wrapped to the next line would not be indented [#5027](https://github.com/rust-lang/rustfmt/issues/5027) + - Prevent rustfmt from adding an `impl Trait` definition into types [#5086](https://github.com/rust-lang/rustfmt/issues/5086) +- Fix cases where `normalize_comments=true` would de-normalizes some comments by changing inline comments into block comments [#4909](https://github.com/rust-lang/rustfmt/issues/4909) +- Prevent rustfmt from wrapping the content of markdown [reference-style links](https://www.markdownguide.org/basic-syntax/#reference-style-links) in doc comments [#5095](https://github.com/rust-lang/rustfmt/issues/5095) [#4933](https://github.com/rust-lang/rustfmt/issues/4933) +- Don't format files annotated with inner `#![rustfmt::skip]` attribute [PR #5094](https://github.com/rust-lang/rustfmt/pull/5094) +- Prevent duplicate comma when struct pattern ends with `..` and `trailing_comma=Always`. For example, `let Foo { a, .. } = b;` would become `let Foo { a,, .. } = b;` [#5066](https://github.com/rust-lang/rustfmt/issues/5066) +- Fix the order of `static` and `async` keywords when rewriting static async closures. The correct order is `static` and then `async` (e.g `static async || {}`) [#5149](https://github.com/rust-lang/rustfmt/issues/5149) +- Retain the fully qualified path segment when rewriting struct literals in expression position. Now `::Type` is not rewritten as `Trait::Type` [#5151](https://github.com/rust-lang/rustfmt/issues/5151) +- Do not remove match arm braces from a match arm with a single `ast::ExprKind::Block` that has leading attributes. Removing the braces could lead to code that does not compile. Now rustfmt will leave the outer `{}` in place when formatting `=> {#[allow(unsafe_code)]unsafe {}}` [#4109](https://github.com/rust-lang/rustfmt/issues/4109) +- Backport json emitter and stdin changes [PR #5054](https://github.com/rust-lang/rustfmt/pull/5054) + - Make `--check` work when running rustfmt with input from stdin [PR #3896](https://github.com/rust-lang/rustfmt/pull/3896) + - Fix `--check` with the `--files-with-diff` flag [PR #3910](https://github.com/rust-lang/rustfmt/pull/3910) + - Produce valid JSON when using the JSON emitter [PR #3953](https://github.com/rust-lang/rustfmt/pull/3953) + - Fix newlines in JSON output [PR #4262](https://github.com/rust-lang/rustfmt/pull/4262) + - Use `` when emitting stdin as filename [PR #4298](https://github.com/rust-lang/rustfmt/pull/4298) +- Always generate some output when formatting `@generated` files via stdin even when `format_generated_files=false`. Not producing output caused rust-analyzer to delete the file content [rust-lang/rust-analyzer](https://github.com/rust-lang/rust-analyzer/issues/11285) [#5172](https://github.com/rust-lang/rustfmt/issues/5172) +- Properly block indent multi-line comments in empty struct definitions. Previously, only the first comment line would be block indented. All other comment lines would be aligned with the struct definition [#4854](https://github.com/rust-lang/rustfmt/issues/4854) +- Prevent rustfmt from wrapping a comment at a byte position inside a non-ascii character when `wrap_comments=true`. This prevents rustfmt from panicking when breaking on the invalid position [#5023](https://github.com/rust-lang/rustfmt/issues/5023) +- Prevent rustfmt from removing commented out trailing separators (e.g commas) when rewriting lists. For example, remove the comma from a comment like this `// ...,` would lead to a scenario where the entire list could not be rewritten because the content of the comment changed [#5042](https://github.com/rust-lang/rustfmt/issues/5042) +- Fix panic when `import_granularity` was set to `Module`, `One`, or `Crate` and the import use declaration contained an alias `use crate a::b as b1` [#5131](https://github.com/rust-lang/rustfmt/issues/5131) +- Add a newline between generic parameters and their doc comments to prevent the generic parameters from being merged into their doc comments [#5122](https://github.com/rust-lang/rustfmt/issues/5122) +- Fixes indentation issue where string literals manually broken with line continuation characters (`\`) would be incorrectly indented in macro definitions when setting `format_strings=true`[#4036](https://github.com/rust-lang/rustfmt/issues/4036) +- Properly wrap and format long markdown block quotes when `wrap_comments=true` [#5157](https://github.com/rust-lang/rustfmt/issues/5157) +- Prevent rustfmt from wrapping markdown headers even when `wrap_comments=true`. Wrapping the markdown headers would prevent them from being properly rendered with rustdoc [#5238](https://github.com/rust-lang/rustfmt/issues/5238) +- Prevent rustfmt from removing commas between struct fields when those fields were also separated by an empty line [#4791](https://github.com/rust-lang/rustfmt/issues/4791) [#4928](https://github.com/rust-lang/rustfmt/issues/4928) +- Fix compiler error caused when formatting imports with `imports_granularity=Module` and a path containing `self`. Given the following import `use crate::lexer::{self, tokens::TokenData};`, rustfmt would transform the `self` import into `use crate::lexer::self;`. Now rustfmt produces `use crate::lexer::{self};` [#4681](https://github.com/rust-lang/rustfmt/issues/4681) +- Prevent rustfmt from breaking long type links in doc comments on namespace qualifiers (`::`) when `wrap_comments=true`. Breaking these long type links over multiple lines prevented them from being properly rendered in rustdoc [#5260](https://github.com/rust-lang/rustfmt/issues/5260) +- Correctly find the start of struct bodies after any generic `const` parameters. Naively searching for an opening `{` lead to issues since generic `const` parameters are also defined with `{}` (e.g. `struct Example {}`) [#5273](https://github.com/rust-lang/rustfmt/issues/5273) +- Prevent rustfmt from merging derives when using inner or outer `rustfmt::skip::attributes` attributes. For example, `#[rustfmt::skip::attributes(derive)]` [#5270](https://github.com/rust-lang/rustfmt/issues/5270) +- Retain trailing `;` when rewriting macro calls in extern blocks. For example, `extern "C" { x!(-); }`[#5281](https://github.com/rust-lang/rustfmt/issues/5281) +- Add a newline when formatting struct fields preceded by both doc comments and inline comments to prevent the field from being merged into the inline comment. This was not an issue when a struct was preceded by just a doc comment or just an inline comment [#5215](https://github.com/rust-lang/rustfmt/issues/5215) + +### Added + +- Added `One` as a new [group_imports](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#group_imports) option to create a single group for all imports [PR #4966](https://github.com/rust-lang/rustfmt/pull/4966) +- Add [short_array_element_width_threshold](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#short_array_element_width_threshold) config option to give users more control over when `Mixed` list formatting is used [PR #5228](https://github.com/rust-lang/rustfmt/pull/5228) + +### Removed + +- Removed unstable, nightly-only config option `report_todo` [#5101](https://github.com/rust-lang/rustfmt/issues/5101) +- Removed unstable, nightly-only config option `report_fixme` [#5102](https://github.com/rust-lang/rustfmt/issues/5102) +- Removed unstable, nightly-only config option `license_template_path` [#5103](https://github.com/rust-lang/rustfmt/issues/5103) + +### Misc + +- Improved performance when formatting large and deeply nested expression trees, often found in generated code, which have many expressions that exceed `max_width` [#5128](https://github.com/rust-lang/rustfmt/issues/5128), [#4867](https://github.com/rust-lang/rustfmt/issues/4867), [#4476](https://github.com/rust-lang/rustfmt/issues/4476), [#5139](https://github.com/rust-lang/rustfmt/pull/5139) + +### Install/Download Options +- **rustup (nightly)** - *pending* +- **GitHub Release Binaries** - [Release v1.5.0](https://github.com/rust-lang/rustfmt/releases/tag/v1.5.0) +- **Build from source** - [Tag v1.5.0](https://github.com/rust-lang/rustfmt/tree/v1.5.0), see instructions for how to [install rustfmt from source][install-from-source] ## [1.4.38] 2021-10-20 diff --git a/src/tools/rustfmt/Cargo.lock b/src/tools/rustfmt/Cargo.lock index b932e15ef74..639d35886dc 100644 --- a/src/tools/rustfmt/Cargo.lock +++ b/src/tools/rustfmt/Cargo.lock @@ -4,64 +4,57 @@ version = 3 [[package]] name = "aho-corasick" -version = "0.7.6" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] [[package]] name = "annotate-snippets" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78ea013094e5ea606b1c05fe35f1dd7ea1eb1ea259908d040b25bd5ec677ee5" +checksum = "c3b9d411ecbaf79885c6df4d75fff75858d5995ff25385657a28af47e82f9c36" dependencies = [ + "unicode-width", "yansi-term", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "anyhow" -version = "1.0.25" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9267dff192e68f3399525901e709a48c1d3982c9c072fa32f2127a0cb0babf14" +checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" [[package]] name = "atty" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ + "hermit-abi", "libc", "winapi", ] [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bstr" -version = "0.2.8" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ "memchr", ] @@ -77,27 +70,27 @@ dependencies = [ [[package]] name = "camino" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52d74260d9bf6944e2208aa46841b4b8f0d7ffc0849a06837b2f510337f86b2b" +checksum = "6f3132262930b0522068049f5870a856ab8affc80c70d08b6ecb785771a6fc23" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0226944a63d1bf35a3b5f948dd7c59e263db83695c9e8bffc4037de02e30f1d7" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" dependencies = [ "serde", ] [[package]] name = "cargo_metadata" -version = "0.14.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c297bd3135f558552f99a0daa180876984ea2c4ffa7470314540dff8c654109a" +checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" dependencies = [ "camino", "cargo-platform", @@ -106,12 +99,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -120,35 +107,49 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.33.0" +version = "3.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +checksum = "71c47df61d9e16dc010b55dba1952a57d8c215dbb533fd13cdd13369aac73b1c" dependencies = [ - "ansi_term", "atty", "bitflags", + "clap_derive", + "indexmap", + "lazy_static", + "os_str_bytes", "strsim", + "termcolor", "textwrap", - "unicode-width", - "vec_map", +] + +[[package]] +name = "clap_derive" +version = "3.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "crossbeam-utils" -version = "0.8.3" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ - "autocfg", - "cfg-if 1.0.0", + "cfg-if", "lazy_static", ] [[package]] name = "derive-new" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9" +checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" dependencies = [ "proc-macro2", "quote", @@ -157,25 +158,45 @@ dependencies = [ [[package]] name = "diff" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a" +checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" [[package]] name = "dirs" -version = "2.0.2" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ - "cfg-if 0.1.10", "dirs-sys", ] [[package]] -name = "dirs-sys" -version = "0.3.6" +name = "dirs-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", @@ -184,15 +205,15 @@ dependencies = [ [[package]] name = "either" -version = "1.5.3" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "env_logger" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54532e3223c5af90a6a757c90b5c5521564b07e5e7a958681bcd2afad421cdcd" +checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" dependencies = [ "atty", "humantime", @@ -203,9 +224,9 @@ dependencies = [ [[package]] name = "fnv" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "getopts" @@ -218,20 +239,20 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "wasi", ] [[package]] name = "globset" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" +checksum = "10463d9ff00a2a068db14231982f5132edebad0d7660cd956a1c30292dbcbfbd" dependencies = [ "aho-corasick", "bstr", @@ -241,12 +262,24 @@ dependencies = [ ] [[package]] -name = "heck" -version = "0.3.1" +name = "hashbrown" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ - "unicode-segmentation", + "libc", ] [[package]] @@ -257,9 +290,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "ignore" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b287fb45c60bb826a0dc68ff08742b9d88a2fea13d6e0c286b3172065aaf878c" +checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" dependencies = [ "crossbeam-utils", "globset", @@ -273,6 +306,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "indexmap" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "itertools" version = "0.10.3" @@ -284,9 +327,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.4" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "lazy_static" @@ -296,9 +339,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.77" +version = "0.2.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" +checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259" [[package]] name = "libm" @@ -308,34 +351,49 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "log" -version = "0.4.14" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] name = "memchr" -version = "2.2.1" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "once_cell" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" + +[[package]] +name = "os_str_bytes" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +dependencies = [ + "memchr", +] [[package]] name = "packed_simd_2" -version = "0.3.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3278e0492f961fd4ae70909f56b2723a7e8d01a228427294e19cdfdebda89a17" +checksum = "defdcfef86dcc44ad208f71d9ff4ce28df6537a4e0d6b0e8e845cb8ca10059a6" dependencies = [ - "cfg-if 0.1.10", + "cfg-if", "libm", ] [[package]] name = "proc-macro-error" -version = "0.4.11" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7959c6467d962050d639361f7703b2051c43036d03493c36f01d440fdd3138a" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", "proc-macro2", @@ -346,71 +404,69 @@ dependencies = [ [[package]] name = "proc-macro-error-attr" -version = "0.4.11" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4002d9f55991d5e019fb940a90e1a95eb80c24e77cb2462dd4dc869604d543a" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ "proc-macro2", "quote", - "syn", - "syn-mid", "version_check", ] [[package]] name = "proc-macro2" -version = "1.0.26" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.6" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" +checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.2.4" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", "redox_syscall", + "thiserror", ] [[package]] name = "regex" -version = "1.4.3" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", ] [[package]] name = "regex-syntax" -version = "0.6.22" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "rustc-workspace-hack" @@ -429,12 +485,13 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "1.4.38" +version = "1.5.0" dependencies = [ "annotate-snippets", "anyhow", "bytecount", "cargo_metadata", + "clap", "derive-new", "diff", "dirs", @@ -449,7 +506,6 @@ dependencies = [ "rustfmt-config_proc_macro", "serde", "serde_json", - "structopt", "term", "thiserror", "toml", @@ -459,43 +515,49 @@ dependencies = [ ] [[package]] -name = "ryu" -version = "1.0.2" +name = "rustversion" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" + +[[package]] +name = "ryu" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "same-file" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ "winapi-util", ] [[package]] name = "semver" -version = "1.0.4" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" +checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.126" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -504,9 +566,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.59" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ "itoa", "ryu", @@ -515,98 +577,61 @@ dependencies = [ [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "structopt" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fe43617218c0805c6eb37160119dc3c548110a67786da7218d1c6555212f073" -dependencies = [ - "clap", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e79c80e0f4efd86ca960218d4e056249be189ff1c42824dcd9a7f51a56f0bd" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.65" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a1d708c221c5a612956ef9f75b37e454e88d1f7b899fbd3a18d4252012d663" +checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] -[[package]] -name = "syn-mid" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "term" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" dependencies = [ - "dirs", + "dirs-next", + "rustversion", "winapi", ] [[package]] name = "termcolor" -version = "1.0.5" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ - "wincolor", + "winapi-util", ] [[package]] name = "textwrap" -version = "0.11.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" -version = "1.0.6" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6b305ec0e323c7b6cfff6098a22516e0063d0bb7c3d88660a890217dca099a" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.6" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ba8d810d9c48fc456b7ad54574e8bfb7c7918a57ad7a6e6a0985d7959e8597" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", @@ -615,39 +640,39 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] name = "toml" -version = "0.5.3" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7aabe75941d914b72bf3e5d3932ed92ce0664d49d8432305a8b547c37227724" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] [[package]] name = "unicode-segmentation" -version = "1.3.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" [[package]] name = "unicode-width" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "unicode_categories" @@ -655,23 +680,17 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" -[[package]] -name = "vec_map" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" - [[package]] name = "version_check" -version = "0.9.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.2.9" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", "winapi", @@ -686,9 +705,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", @@ -702,9 +721,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi", ] @@ -715,16 +734,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "wincolor" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" -dependencies = [ - "winapi", - "winapi-util", -] - [[package]] name = "yansi-term" version = "0.1.2" diff --git a/src/tools/rustfmt/Cargo.toml b/src/tools/rustfmt/Cargo.toml index 764714638a9..f26e9824062 100644 --- a/src/tools/rustfmt/Cargo.toml +++ b/src/tools/rustfmt/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustfmt-nightly" -version = "1.4.38" +version = "1.5.0" description = "Tool to find and fix Rust formatting issues" repository = "https://github.com/rust-lang/rustfmt" readme = "README.md" @@ -33,30 +33,31 @@ rustfmt-format-diff = [] generic-simd = ["bytecount/generic-simd"] [dependencies] -itertools = "0.10.1" -toml = "0.5" +annotate-snippets = { version = "0.9", features = ["color"] } +anyhow = "1.0" +bytecount = "0.6" +cargo_metadata = "0.14" +clap = { version = "3.1", features = ["derive"] } +derive-new = "0.5" +diff = "0.1" +dirs = "4.0" +env_logger = "0.9" +getopts = "0.2" +ignore = "0.4" +itertools = "0.10" +lazy_static = "1.4" +log = "0.4" +regex = "1.5" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -unicode-segmentation = "1.0.0" -regex = "1.0" -term = "0.6" -diff = "0.1" -log = "0.4.14" -env_logger = "0.8" -getopts = "0.2" -derive-new = "0.5" -cargo_metadata = "0.14" -bytecount = "0.6" -unicode-width = "0.1.5" -unicode_categories = "0.1.1" -dirs = "2.0.1" -ignore = "0.4.17" -annotate-snippets = { version = "0.8", features = ["color"] } -structopt = "0.3" -rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" } -lazy_static = "1.0.0" -anyhow = "1.0" +term = "0.7" thiserror = "1.0" +toml = "0.5" +unicode-segmentation = "1.9" +unicode-width = "0.1" +unicode_categories = "0.1" + +rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" } # A noop dependency that changes in the Rust repository, it's a bit of a hack. # See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust` diff --git a/src/tools/rustfmt/Configurations.md b/src/tools/rustfmt/Configurations.md index a47439b9ba9..8c84614352c 100644 --- a/src/tools/rustfmt/Configurations.md +++ b/src/tools/rustfmt/Configurations.md @@ -10,7 +10,7 @@ reorder_imports = false ``` Each configuration option is either stable or unstable. -Stable options can be used directly, while unstable options are opt-in. +Stable options can always be used, while unstable options are only available on a nightly toolchain and must be opted into. To enable unstable options, set `unstable_features = true` in `rustfmt.toml` or pass `--unstable-features` to rustfmt. # Configuration Options @@ -1065,7 +1065,7 @@ See also: [`tab_spaces`](#tab_spaces). Control the case of the letters in hexadecimal literal values - **Default value**: `Preserve` -- **Possible values**: `Upper`, `Lower` +- **Possible values**: `Preserve`, `Upper`, `Lower` - **Stable**: No (tracking issue: [#5081](https://github.com/rust-lang/rustfmt/issues/5081)) ## `hide_parse_errors` @@ -1473,26 +1473,6 @@ use core::slice; #[cfg(feature = "alloc")] use core::slice; ``` -## `license_template_path` - -Check whether beginnings of files match a license template. - -- **Default value**: `""` -- **Possible values**: path to a license template file -- **Stable**: No (tracking issue: [#3352](https://github.com/rust-lang/rustfmt/issues/3352)) - -A license template is a plain text file which is matched literally against the -beginning of each source file, except for `{}`-delimited blocks, which are -matched as regular expressions. The following license template therefore -matches strings like `// Copyright 2017 The Rust Project Developers.`, `// -Copyright 2018 The Rust Project Developers.`, etc.: - -``` -// Copyright {\d+} The Rust Project Developers. -``` - -`\{`, `\}` and `\\` match literal braces / backslashes. - ## `match_arm_blocks` Controls whether arm bodies are wrapped in cases where the first line of the body cannot fit on the same line as the `=>` operator. @@ -1705,6 +1685,8 @@ How imports should be grouped into `use` statements. Imports will be merged or s - **Possible values**: `Preserve`, `Crate`, `Module`, `Item`, `One` - **Stable**: No (tracking issue: [#4991](https://github.com/rust-lang/rustfmt/issues/4991)) +Note that rustfmt will not modify the granularity of imports containing comments if doing so could potentially lose or misplace said comments. + #### `Preserve` (default): Do not change the granularity of any imports and preserve the original structure written by the developer. @@ -2061,12 +2043,16 @@ use sit; ## `group_imports` -Controls the strategy for how imports are grouped together. +Controls the strategy for how consecutive imports are grouped together. + +Controls the strategy for grouping sets of consecutive imports. Imports may contain newlines between imports and still be grouped together as a single set, but other statements between imports will result in different grouping sets. - **Default value**: `Preserve` - **Possible values**: `Preserve`, `StdExternalCrate`, `One` - **Stable**: No (tracking issue: [#5083](https://github.com/rust-lang/rustfmt/issues/5083)) +Each set of imports (one or more `use` statements, optionally separated by newlines) will be formatted independently. Other statements such as `mod ...` or `extern crate ...` will cause imports to not be grouped together. + #### `Preserve` (default): Preserve the source file's import groups. @@ -2162,35 +2148,6 @@ mod sit; **Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantics of the original source code. -## `report_fixme` - -Report `FIXME` items in comments. - -- **Default value**: `"Never"` -- **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"` -- **Stable**: No (tracking issue: [#3394](https://github.com/rust-lang/rustfmt/issues/3394)) - -Warns about any comments containing `FIXME` in them when set to `"Always"`. If -it contains a `#X` (with `X` being a number) in parentheses following the -`FIXME`, `"Unnumbered"` will ignore it. - -See also [`report_todo`](#report_todo). - - -## `report_todo` - -Report `TODO` items in comments. - -- **Default value**: `"Never"` -- **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"` -- **Stable**: No (tracking issue: [#3393](https://github.com/rust-lang/rustfmt/issues/3393)) - -Warns about any comments containing `TODO` in them when set to `"Always"`. If -it contains a `#X` (with `X` being a number) in parentheses following the -`TODO`, `"Unnumbered"` will ignore it. - -See also [`report_fixme`](#report_fixme). - ## `required_version` Require a specific version of rustfmt. If you want to make sure that the diff --git a/src/tools/rustfmt/rust-toolchain b/src/tools/rustfmt/rust-toolchain index 94b57d506c2..813e5e2c10f 100644 --- a/src/tools/rustfmt/rust-toolchain +++ b/src/tools/rustfmt/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2022-03-27" +channel = "nightly-2022-06-06" components = ["rustc-dev"] diff --git a/src/tools/rustfmt/src/cargo-fmt/main.rs b/src/tools/rustfmt/src/cargo-fmt/main.rs index 8cb7b4585ec..55fd75f6de9 100644 --- a/src/tools/rustfmt/src/cargo-fmt/main.rs +++ b/src/tools/rustfmt/src/cargo-fmt/main.rs @@ -10,59 +10,63 @@ use std::ffi::OsStr; use std::fs; use std::hash::{Hash, Hasher}; use std::io::{self, Write}; -use std::iter::FromIterator; use std::path::{Path, PathBuf}; use std::process::Command; use std::str; -use structopt::StructOpt; +use clap::{CommandFactory, Parser}; #[path = "test/mod.rs"] #[cfg(test)] mod cargo_fmt_tests; -#[derive(StructOpt, Debug)] -#[structopt( +#[derive(Parser)] +#[clap( bin_name = "cargo fmt", about = "This utility formats all bin and lib files of \ the current crate using rustfmt." )] pub struct Opts { /// No output printed to stdout - #[structopt(short = "q", long = "quiet")] + #[clap(short = 'q', long = "quiet")] quiet: bool, /// Use verbose output - #[structopt(short = "v", long = "verbose")] + #[clap(short = 'v', long = "verbose")] verbose: bool, /// Print rustfmt version and exit - #[structopt(long = "version")] + #[clap(long = "version")] version: bool, /// Specify package to format - #[structopt(short = "p", long = "package", value_name = "package")] + #[clap( + short = 'p', + long = "package", + value_name = "package", + multiple_values = true + )] packages: Vec, /// Specify path to Cargo.toml - #[structopt(long = "manifest-path", value_name = "manifest-path")] + #[clap(long = "manifest-path", value_name = "manifest-path")] manifest_path: Option, /// Specify message-format: short|json|human - #[structopt(long = "message-format", value_name = "message-format")] + #[clap(long = "message-format", value_name = "message-format")] message_format: Option, /// Options passed to rustfmt // 'raw = true' to make `--` explicit. - #[structopt(name = "rustfmt_options", raw(true))] + #[clap(name = "rustfmt_options", raw(true))] rustfmt_options: Vec, /// Format all packages, and also their local path-based dependencies - #[structopt(long = "all")] + #[clap(long = "all")] format_all: bool, /// Run rustfmt in check mode - #[structopt(long = "check")] + #[clap(long = "check")] check: bool, } @@ -87,7 +91,7 @@ fn execute() -> i32 { } }); - let opts = Opts::from_iter(args); + let opts = Opts::parse_from(args); let verbosity = match (opts.verbose, opts.quiet) { (false, false) => Verbosity::Normal, @@ -204,7 +208,7 @@ fn convert_message_format_to_rustfmt_args( fn print_usage_to_stderr(reason: &str) { eprintln!("{}", reason); - let app = Opts::clap(); + let app = Opts::command(); app.after_help("") .write_help(&mut io::stderr()) .expect("failed to write to stderr"); diff --git a/src/tools/rustfmt/src/cargo-fmt/test/mod.rs b/src/tools/rustfmt/src/cargo-fmt/test/mod.rs index 360503632c7..56e52fbabb6 100644 --- a/src/tools/rustfmt/src/cargo-fmt/test/mod.rs +++ b/src/tools/rustfmt/src/cargo-fmt/test/mod.rs @@ -6,7 +6,7 @@ mod targets; #[test] fn default_options() { let empty: Vec = vec![]; - let o = Opts::from_iter(&empty); + let o = Opts::parse_from(&empty); assert_eq!(false, o.quiet); assert_eq!(false, o.verbose); assert_eq!(false, o.version); @@ -20,7 +20,7 @@ fn default_options() { #[test] fn good_options() { - let o = Opts::from_iter(&[ + let o = Opts::parse_from(&[ "test", "-q", "-p", @@ -47,8 +47,8 @@ fn good_options() { #[test] fn unexpected_option() { assert!( - Opts::clap() - .get_matches_from_safe(&["test", "unexpected"]) + Opts::command() + .try_get_matches_from(&["test", "unexpected"]) .is_err() ); } @@ -56,8 +56,8 @@ fn unexpected_option() { #[test] fn unexpected_flag() { assert!( - Opts::clap() - .get_matches_from_safe(&["test", "--flag"]) + Opts::command() + .try_get_matches_from(&["test", "--flag"]) .is_err() ); } @@ -65,20 +65,20 @@ fn unexpected_flag() { #[test] fn mandatory_separator() { assert!( - Opts::clap() - .get_matches_from_safe(&["test", "--emit"]) + Opts::command() + .try_get_matches_from(&["test", "--emit"]) .is_err() ); assert!( - !Opts::clap() - .get_matches_from_safe(&["test", "--", "--emit"]) + !Opts::command() + .try_get_matches_from(&["test", "--", "--emit"]) .is_err() ); } #[test] fn multiple_packages_one_by_one() { - let o = Opts::from_iter(&[ + let o = Opts::parse_from(&[ "test", "-p", "package1", @@ -92,7 +92,7 @@ fn multiple_packages_one_by_one() { #[test] fn multiple_packages_grouped() { - let o = Opts::from_iter(&[ + let o = Opts::parse_from(&[ "test", "--package", "package1", @@ -106,14 +106,18 @@ fn multiple_packages_grouped() { #[test] fn empty_packages_1() { - assert!(Opts::clap().get_matches_from_safe(&["test", "-p"]).is_err()); + assert!( + Opts::command() + .try_get_matches_from(&["test", "-p"]) + .is_err() + ); } #[test] fn empty_packages_2() { assert!( - Opts::clap() - .get_matches_from_safe(&["test", "-p", "--", "--check"]) + Opts::command() + .try_get_matches_from(&["test", "-p", "--", "--check"]) .is_err() ); } @@ -121,8 +125,8 @@ fn empty_packages_2() { #[test] fn empty_packages_3() { assert!( - Opts::clap() - .get_matches_from_safe(&["test", "-p", "--verbose"]) + Opts::command() + .try_get_matches_from(&["test", "-p", "--verbose"]) .is_err() ); } @@ -130,8 +134,8 @@ fn empty_packages_3() { #[test] fn empty_packages_4() { assert!( - Opts::clap() - .get_matches_from_safe(&["test", "-p", "--check"]) + Opts::command() + .try_get_matches_from(&["test", "-p", "--check"]) .is_err() ); } diff --git a/src/tools/rustfmt/src/comment.rs b/src/tools/rustfmt/src/comment.rs index f9d8a0fa70c..eb195b1f762 100644 --- a/src/tools/rustfmt/src/comment.rs +++ b/src/tools/rustfmt/src/comment.rs @@ -796,7 +796,7 @@ impl<'a> CommentRewrite<'a> { // 1) wrap_comments = true is configured // 2) The comment is not the start of a markdown header doc comment // 3) The comment width exceeds the shape's width - // 4) No URLS were found in the commnet + // 4) No URLS were found in the comment let should_wrap_comment = self.fmt.config.wrap_comments() && !is_markdown_header_doc_comment && unicode_str_width(line) > self.fmt.shape.width diff --git a/src/tools/rustfmt/src/config/config_type.rs b/src/tools/rustfmt/src/config/config_type.rs index 7fc4486ddcd..e37ed798cb5 100644 --- a/src/tools/rustfmt/src/config/config_type.rs +++ b/src/tools/rustfmt/src/config/config_type.rs @@ -61,9 +61,6 @@ macro_rules! create_config { #[derive(Clone)] #[allow(unreachable_pub)] pub struct Config { - // if a license_template_path has been specified, successfully read, parsed and compiled - // into a regex, it will be stored here - pub license_template: Option, // For each config item, we store a bool indicating whether it has // been accessed and the value, and a bool whether the option was // manually initialised, or taken from the default, @@ -104,7 +101,6 @@ macro_rules! create_config { | "struct_variant_width" | "array_width" | "chain_width" => self.0.set_heuristics(), - "license_template_path" => self.0.set_license_template(), "merge_imports" => self.0.set_merge_imports(), &_ => (), } @@ -163,7 +159,6 @@ macro_rules! create_config { } )+ self.set_heuristics(); - self.set_license_template(); self.set_ignore(dir); self.set_merge_imports(); self @@ -247,7 +242,6 @@ macro_rules! create_config { | "struct_variant_width" | "array_width" | "chain_width" => self.set_heuristics(), - "license_template_path" => self.set_license_template(), "merge_imports" => self.set_merge_imports(), &_ => (), } @@ -386,21 +380,6 @@ macro_rules! create_config { }; } - fn set_license_template(&mut self) { - if self.was_set().license_template_path() { - let lt_path = self.license_template_path(); - if lt_path.len() > 0 { - match license::load_and_compile_template(<_path) { - Ok(re) => self.license_template = Some(re), - Err(msg) => eprintln!("Warning for license template file {:?}: {}", - lt_path, msg), - } - } else { - self.license_template = None; - } - } - } - fn set_ignore(&mut self, dir: &Path) { self.ignore.2.add_prefix(dir); } @@ -437,7 +416,6 @@ macro_rules! create_config { impl Default for Config { fn default() -> Config { Config { - license_template: None, $( $i: (Cell::new(false), false, $def, $stb), )+ diff --git a/src/tools/rustfmt/src/config/license.rs b/src/tools/rustfmt/src/config/license.rs deleted file mode 100644 index c7feb502ea9..00000000000 --- a/src/tools/rustfmt/src/config/license.rs +++ /dev/null @@ -1,265 +0,0 @@ -use std::fmt; -use std::fs::File; -use std::io; -use std::io::Read; - -use regex::Regex; - -#[derive(Debug)] -pub(crate) enum LicenseError { - IO(io::Error), - Regex(regex::Error), - Parse(String), -} - -impl fmt::Display for LicenseError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self { - LicenseError::IO(ref err) => err.fmt(f), - LicenseError::Regex(ref err) => err.fmt(f), - LicenseError::Parse(ref err) => write!(f, "parsing failed, {}", err), - } - } -} - -impl From for LicenseError { - fn from(err: io::Error) -> LicenseError { - LicenseError::IO(err) - } -} - -impl From for LicenseError { - fn from(err: regex::Error) -> LicenseError { - LicenseError::Regex(err) - } -} - -// the template is parsed using a state machine -enum ParsingState { - Lit, - LitEsc, - // the u32 keeps track of brace nesting - Re(u32), - ReEsc(u32), - Abort(String), -} - -use self::ParsingState::*; - -pub(crate) struct TemplateParser { - parsed: String, - buffer: String, - state: ParsingState, - linum: u32, - open_brace_line: u32, -} - -impl TemplateParser { - fn new() -> Self { - Self { - parsed: "^".to_owned(), - buffer: String::new(), - state: Lit, - linum: 1, - // keeps track of last line on which a regex placeholder was started - open_brace_line: 0, - } - } - - /// Converts a license template into a string which can be turned into a regex. - /// - /// The license template could use regex syntax directly, but that would require a lot of manual - /// escaping, which is inconvenient. It is therefore literal by default, with optional regex - /// subparts delimited by `{` and `}`. Additionally: - /// - /// - to insert literal `{`, `}` or `\`, escape it with `\` - /// - an empty regex placeholder (`{}`) is shorthand for `{.*?}` - /// - /// This function parses this input format and builds a properly escaped *string* representation - /// of the equivalent regular expression. It **does not** however guarantee that the returned - /// string is a syntactically valid regular expression. - /// - /// # Examples - /// - /// ```text - /// assert_eq!( - /// TemplateParser::parse( - /// r" - /// // Copyright {\d+} The \} Rust \\ Project \{ Developers. See the {([A-Z]+)} - /// // file at the top-level directory of this distribution and at - /// // {}. - /// // - /// // Licensed under the Apache License, Version 2.0 or the MIT license - /// // , at your - /// // option. This file may not be copied, modified, or distributed - /// // except according to those terms. - /// " - /// ).unwrap(), - /// r"^ - /// // Copyright \d+ The \} Rust \\ Project \{ Developers\. See the ([A-Z]+) - /// // file at the top\-level directory of this distribution and at - /// // .*?\. - /// // - /// // Licensed under the Apache License, Version 2\.0 or the MIT license - /// // , at your - /// // option\. This file may not be copied, modified, or distributed - /// // except according to those terms\. - /// " - /// ); - /// ``` - pub(crate) fn parse(template: &str) -> Result { - let mut parser = Self::new(); - for chr in template.chars() { - if chr == '\n' { - parser.linum += 1; - } - parser.state = match parser.state { - Lit => parser.trans_from_lit(chr), - LitEsc => parser.trans_from_litesc(chr), - Re(brace_nesting) => parser.trans_from_re(chr, brace_nesting), - ReEsc(brace_nesting) => parser.trans_from_reesc(chr, brace_nesting), - Abort(msg) => return Err(LicenseError::Parse(msg)), - }; - } - // check if we've ended parsing in a valid state - match parser.state { - Abort(msg) => return Err(LicenseError::Parse(msg)), - Re(_) | ReEsc(_) => { - return Err(LicenseError::Parse(format!( - "escape or balance opening brace on l. {}", - parser.open_brace_line - ))); - } - LitEsc => { - return Err(LicenseError::Parse(format!( - "incomplete escape sequence on l. {}", - parser.linum - ))); - } - _ => (), - } - parser.parsed.push_str(®ex::escape(&parser.buffer)); - - Ok(parser.parsed) - } - - fn trans_from_lit(&mut self, chr: char) -> ParsingState { - match chr { - '{' => { - self.parsed.push_str(®ex::escape(&self.buffer)); - self.buffer.clear(); - self.open_brace_line = self.linum; - Re(1) - } - '}' => Abort(format!( - "escape or balance closing brace on l. {}", - self.linum - )), - '\\' => LitEsc, - _ => { - self.buffer.push(chr); - Lit - } - } - } - - fn trans_from_litesc(&mut self, chr: char) -> ParsingState { - self.buffer.push(chr); - Lit - } - - fn trans_from_re(&mut self, chr: char, brace_nesting: u32) -> ParsingState { - match chr { - '{' => { - self.buffer.push(chr); - Re(brace_nesting + 1) - } - '}' => { - match brace_nesting { - 1 => { - // default regex for empty placeholder {} - if self.buffer.is_empty() { - self.parsed.push_str(".*?"); - } else { - self.parsed.push_str(&self.buffer); - } - self.buffer.clear(); - Lit - } - _ => { - self.buffer.push(chr); - Re(brace_nesting - 1) - } - } - } - '\\' => { - self.buffer.push(chr); - ReEsc(brace_nesting) - } - _ => { - self.buffer.push(chr); - Re(brace_nesting) - } - } - } - - fn trans_from_reesc(&mut self, chr: char, brace_nesting: u32) -> ParsingState { - self.buffer.push(chr); - Re(brace_nesting) - } -} - -pub(crate) fn load_and_compile_template(path: &str) -> Result { - let mut lt_file = File::open(&path)?; - let mut lt_str = String::new(); - lt_file.read_to_string(&mut lt_str)?; - let lt_parsed = TemplateParser::parse(<_str)?; - Ok(Regex::new(<_parsed)?) -} - -#[cfg(test)] -mod test { - use super::TemplateParser; - - #[test] - fn test_parse_license_template() { - assert_eq!( - TemplateParser::parse("literal (.*)").unwrap(), - r"^literal \(\.\*\)" - ); - assert_eq!( - TemplateParser::parse(r"escaping \}").unwrap(), - r"^escaping \}" - ); - assert!(TemplateParser::parse("unbalanced } without escape").is_err()); - assert_eq!( - TemplateParser::parse(r"{\d+} place{-?}holder{s?}").unwrap(), - r"^\d+ place-?holders?" - ); - assert_eq!(TemplateParser::parse("default {}").unwrap(), "^default .*?"); - assert_eq!( - TemplateParser::parse(r"unbalanced nested braces {\{{3}}").unwrap(), - r"^unbalanced nested braces \{{3}" - ); - assert_eq!( - &TemplateParser::parse("parsing error }") - .unwrap_err() - .to_string(), - "parsing failed, escape or balance closing brace on l. 1" - ); - assert_eq!( - &TemplateParser::parse("parsing error {\nsecond line") - .unwrap_err() - .to_string(), - "parsing failed, escape or balance opening brace on l. 1" - ); - assert_eq!( - &TemplateParser::parse(r"parsing error \") - .unwrap_err() - .to_string(), - "parsing failed, incomplete escape sequence on l. 1" - ); - } -} diff --git a/src/tools/rustfmt/src/config/mod.rs b/src/tools/rustfmt/src/config/mod.rs index 18e1854612b..a5169528187 100644 --- a/src/tools/rustfmt/src/config/mod.rs +++ b/src/tools/rustfmt/src/config/mod.rs @@ -5,7 +5,6 @@ use std::io::{Error, ErrorKind, Read}; use std::path::{Path, PathBuf}; use std::{env, fs}; -use regex::Regex; use thiserror::Error; use crate::config::config_type::ConfigType; @@ -22,7 +21,6 @@ pub(crate) mod config_type; pub(crate) mod options; pub(crate) mod file_lines; -pub(crate) mod license; pub(crate) mod lists; // This macro defines configuration options used in rustfmt. Each option @@ -63,8 +61,6 @@ create_config! { "Maximum length of comments. No effect unless wrap_comments = true"; normalize_comments: bool, false, false, "Convert /* */ comments to // comments where possible"; normalize_doc_attributes: bool, false, false, "Normalize doc attributes as doc comments"; - license_template_path: String, String::default(), false, - "Beginning of file must match license template"; format_strings: bool, false, false, "Format string literals where necessary"; format_macro_matchers: bool, false, false, "Format the metavariable matching patterns in macros"; @@ -164,10 +160,6 @@ create_config! { error_on_unformatted: bool, false, false, "Error if unable to get comments or string literals within max_width, \ or they are left with trailing whitespaces"; - report_todo: ReportTactic, ReportTactic::Never, false, - "Report all, none or unnumbered occurrences of TODO in source file comments"; - report_fixme: ReportTactic, ReportTactic::Never, false, - "Report all, none or unnumbered occurrences of FIXME in source file comments"; ignore: IgnoreList, IgnoreList::default(), false, "Skip formatting the specified files and directories"; @@ -418,8 +410,6 @@ mod test { create_config! { // Options that are used by the generated functions max_width: usize, 100, true, "Maximum width of each line"; - license_template_path: String, String::default(), false, - "Beginning of file must match license template"; required_version: String, env!("CARGO_PKG_VERSION").to_owned(), false, "Require a specific version of rustfmt."; ignore: IgnoreList, IgnoreList::default(), false, @@ -524,31 +514,6 @@ mod test { assert_eq!(s.contains("(unstable)"), true); } - #[test] - fn test_empty_string_license_template_path() { - let toml = r#"license_template_path = """#; - let config = Config::from_toml(toml, Path::new("")).unwrap(); - assert!(config.license_template.is_none()); - } - - #[nightly_only_test] - #[test] - fn test_valid_license_template_path() { - let toml = r#"license_template_path = "tests/license-template/lt.txt""#; - let config = Config::from_toml(toml, Path::new("")).unwrap(); - assert!(config.license_template.is_some()); - } - - #[nightly_only_test] - #[test] - fn test_override_existing_license_with_no_license() { - let toml = r#"license_template_path = "tests/license-template/lt.txt""#; - let mut config = Config::from_toml(toml, Path::new("")).unwrap(); - assert!(config.license_template.is_some()); - config.override_value("license_template_path", ""); - assert!(config.license_template.is_none()); - } - #[test] fn test_dump_default_config() { let default_config = format!( @@ -570,7 +535,6 @@ format_code_in_doc_comments = false comment_width = 80 normalize_comments = false normalize_doc_attributes = false -license_template_path = "" format_strings = false format_macro_matchers = false format_macro_bodies = true @@ -625,8 +589,6 @@ skip_children = false hide_parse_errors = false error_on_line_overflow = false error_on_unformatted = false -report_todo = "Never" -report_fixme = "Never" ignore = [] emit_mode = "Files" make_backup = false diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index e4cc93026f1..4ccf1ca70c9 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -1,5 +1,6 @@ use std::borrow::Cow; use std::cmp::min; +use std::collections::HashMap; use itertools::Itertools; use rustc_ast::token::{Delimiter, LitKind}; @@ -22,7 +23,7 @@ use crate::macros::{rewrite_macro, MacroPosition}; use crate::matches::rewrite_match; use crate::overflow::{self, IntoOverflowableItem, OverflowableItem}; use crate::pairs::{rewrite_all_pairs, rewrite_pair, PairParts}; -use crate::rewrite::{Rewrite, RewriteContext}; +use crate::rewrite::{QueryId, Rewrite, RewriteContext}; use crate::shape::{Indent, Shape}; use crate::source_map::{LineRangeUtils, SpanUtils}; use crate::spanned::Spanned; @@ -53,6 +54,54 @@ pub(crate) fn format_expr( expr_type: ExprType, context: &RewriteContext<'_>, shape: Shape, +) -> Option { + // when max_width is tight, we should check all possible formattings, in order to find + // if we can fit expression in the limit. Doing it recursively takes exponential time + // relative to input size, and people hit it with rustfmt takes minutes in #4476 #4867 #5128 + // By memoization of format_expr function, we format each pair of expression and shape + // only once, so worst case execution time becomes O(n*max_width^3). + if context.inside_macro() || context.is_macro_def { + // span ids are not unique in macros, so we don't memoize result of them. + return format_expr_inner(expr, expr_type, context, shape); + } + let clean; + let query_id = QueryId { + shape, + span: expr.span, + }; + if let Some(map) = context.memoize.take() { + if let Some(r) = map.get(&query_id) { + let r = r.clone(); + context.memoize.set(Some(map)); // restore map in the memoize cell for other users + return r; + } + context.memoize.set(Some(map)); + clean = false; + } else { + context.memoize.set(Some(HashMap::default())); + clean = true; // We got None, so we are the top level called function. When + // this function finishes, no one is interested in what is in the map, because + // all of them are sub expressions of this top level expression, and this is + // done. So we should clean up memoize map to save some memory. + } + + let r = format_expr_inner(expr, expr_type, context, shape); + if clean { + context.memoize.set(None); + } else { + if let Some(mut map) = context.memoize.take() { + map.insert(query_id, r.clone()); // insert the result in the memoize map + context.memoize.set(Some(map)); // so it won't be computed again + } + } + r +} + +fn format_expr_inner( + expr: &ast::Expr, + expr_type: ExprType, + context: &RewriteContext<'_>, + shape: Shape, ) -> Option { skip_out_of_file_lines_range!(context, expr.span); diff --git a/src/tools/rustfmt/src/format-diff/main.rs b/src/tools/rustfmt/src/format-diff/main.rs index 655aeda42bf..f6b739e1c2a 100644 --- a/src/tools/rustfmt/src/format-diff/main.rs +++ b/src/tools/rustfmt/src/format-diff/main.rs @@ -19,8 +19,7 @@ use std::process; use regex::Regex; -use structopt::clap::AppSettings; -use structopt::StructOpt; +use clap::{CommandFactory, Parser}; /// The default pattern of files to format. /// @@ -37,16 +36,16 @@ enum FormatDiffError { IoError(#[from] io::Error), } -#[derive(StructOpt, Debug)] -#[structopt( +#[derive(Parser, Debug)] +#[clap( name = "rustfmt-format-diff", - setting = AppSettings::DisableVersion, - setting = AppSettings::NextLineHelp + disable_version_flag = true, + next_line_help = true )] pub struct Opts { /// Skip the smallest prefix containing NUMBER slashes - #[structopt( - short = "p", + #[clap( + short = 'p', long = "skip-prefix", value_name = "NUMBER", default_value = "0" @@ -54,8 +53,8 @@ pub struct Opts { skip_prefix: u32, /// Custom pattern selecting file paths to reformat - #[structopt( - short = "f", + #[clap( + short = 'f', long = "filter", value_name = "PATTERN", default_value = DEFAULT_PATTERN @@ -65,10 +64,12 @@ pub struct Opts { fn main() { env_logger::Builder::from_env("RUSTFMT_LOG").init(); - let opts = Opts::from_args(); + let opts = Opts::parse(); if let Err(e) = run(opts) { println!("{}", e); - Opts::clap().print_help().expect("cannot write to stdout"); + Opts::command() + .print_help() + .expect("cannot write to stdout"); process::exit(1); } } @@ -230,14 +231,14 @@ mod cmd_line_tests { #[test] fn default_options() { let empty: Vec = vec![]; - let o = Opts::from_iter(&empty); + let o = Opts::parse_from(&empty); assert_eq!(DEFAULT_PATTERN, o.filter); assert_eq!(0, o.skip_prefix); } #[test] fn good_options() { - let o = Opts::from_iter(&["test", "-p", "10", "-f", r".*\.hs"]); + let o = Opts::parse_from(&["test", "-p", "10", "-f", r".*\.hs"]); assert_eq!(r".*\.hs", o.filter); assert_eq!(10, o.skip_prefix); } @@ -245,8 +246,8 @@ mod cmd_line_tests { #[test] fn unexpected_option() { assert!( - Opts::clap() - .get_matches_from_safe(&["test", "unexpected"]) + Opts::command() + .try_get_matches_from(&["test", "unexpected"]) .is_err() ); } @@ -254,8 +255,8 @@ mod cmd_line_tests { #[test] fn unexpected_flag() { assert!( - Opts::clap() - .get_matches_from_safe(&["test", "--flag"]) + Opts::command() + .try_get_matches_from(&["test", "--flag"]) .is_err() ); } @@ -263,8 +264,8 @@ mod cmd_line_tests { #[test] fn overridden_option() { assert!( - Opts::clap() - .get_matches_from_safe(&["test", "-p", "10", "-p", "20"]) + Opts::command() + .try_get_matches_from(&["test", "-p", "10", "-p", "20"]) .is_err() ); } @@ -272,8 +273,8 @@ mod cmd_line_tests { #[test] fn negative_filter() { assert!( - Opts::clap() - .get_matches_from_safe(&["test", "-p", "-1"]) + Opts::command() + .try_get_matches_from(&["test", "-p", "-1"]) .is_err() ); } diff --git a/src/tools/rustfmt/src/format_report_formatter.rs b/src/tools/rustfmt/src/format_report_formatter.rs index 90406cdb95e..fd536d4df41 100644 --- a/src/tools/rustfmt/src/format_report_formatter.rs +++ b/src/tools/rustfmt/src/format_report_formatter.rs @@ -142,10 +142,9 @@ fn error_kind_to_snippet_annotation_type(error_kind: &ErrorKind) -> AnnotationTy | ErrorKind::ModuleResolutionError(_) | ErrorKind::ParseError | ErrorKind::LostComment - | ErrorKind::LicenseCheck | ErrorKind::BadAttr | ErrorKind::InvalidGlobPattern(_) | ErrorKind::VersionMismatch => AnnotationType::Error, - ErrorKind::BadIssue(_) | ErrorKind::DeprecatedAttr => AnnotationType::Warning, + ErrorKind::DeprecatedAttr => AnnotationType::Warning, } } diff --git a/src/tools/rustfmt/src/formatting.rs b/src/tools/rustfmt/src/formatting.rs index ebadf3dd598..e644ea50eff 100644 --- a/src/tools/rustfmt/src/formatting.rs +++ b/src/tools/rustfmt/src/formatting.rs @@ -2,6 +2,7 @@ use std::collections::HashMap; use std::io::{self, Write}; +use std::rc::Rc; use std::time::{Duration, Instant}; use rustc_ast::ast; @@ -11,7 +12,6 @@ use self::newline_style::apply_newline_style; use crate::comment::{CharClasses, FullCodeCharKind}; use crate::config::{Config, FileName, Verbosity}; use crate::formatting::generated::is_generated_file; -use crate::issues::BadIssueSeeker; use crate::modules::Module; use crate::parse::parser::{DirectoryOwnership, Parser, ParserError}; use crate::parse::session::ParseSess; @@ -39,12 +39,10 @@ impl<'b, T: Write + 'b> Session<'b, T> { rustc_span::create_session_if_not_set_then(self.config.edition().into(), |_| { if self.config.disable_all_formatting() { // When the input is from stdin, echo back the input. - if let Input::Text(ref buf) = input { - if let Err(e) = io::stdout().write_all(buf.as_bytes()) { - return Err(From::from(e)); - } - } - return Ok(FormatReport::new()); + return match input { + Input::Text(ref buf) => echo_back_stdin(buf), + _ => Ok(FormatReport::new()), + }; } let config = &self.config.clone(); @@ -93,6 +91,13 @@ fn should_skip_module( false } +fn echo_back_stdin(input: &str) -> Result { + if let Err(e) = io::stdout().write_all(input.as_bytes()) { + return Err(From::from(e)); + } + Ok(FormatReport::new()) +} + // Format an entire crate (or subset of the module tree). fn format_project( input: Input, @@ -135,7 +140,8 @@ fn format_project( .visit_crate(&krate)? .into_iter() .filter(|(path, module)| { - !should_skip_module(config, &context, input_is_stdin, &main_file, path, module) + input_is_stdin + || !should_skip_module(config, &context, input_is_stdin, &main_file, path, module) }) .collect::>(); @@ -145,6 +151,14 @@ fn format_project( context.parse_session.set_silent_emitter(); for (path, module) in files { + if input_is_stdin && contains_skip(module.attrs()) { + return echo_back_stdin( + context + .parse_session + .snippet_provider(module.span) + .entire_snippet(), + ); + } should_emit_verbose(input_is_stdin, config, || println!("Formatting {}", path)); context.format_file(path, &module, is_macro_def)?; } @@ -189,6 +203,7 @@ impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> { self.config, &snippet_provider, self.report.clone(), + Rc::default(), ); visitor.skip_context.update_with_attrs(&self.krate.attrs); visitor.is_macro_def = is_macro_def; @@ -329,10 +344,8 @@ impl FormattingError { ErrorKind::LineOverflow(found, max) => (max, found - max), ErrorKind::TrailingWhitespace | ErrorKind::DeprecatedAttr - | ErrorKind::BadIssue(_) | ErrorKind::BadAttr - | ErrorKind::LostComment - | ErrorKind::LicenseCheck => { + | ErrorKind::LostComment => { let trailing_ws_start = self .line_buffer .rfind(|c: char| !c.is_whitespace()) @@ -364,7 +377,7 @@ pub(crate) struct ReportedErrors { // Code contains macro call that was unable to format. pub(crate) has_macro_format_failure: bool, - // Failed a check, such as the license check or other opt-in checking. + // Failed an opt-in checking. pub(crate) has_check_errors: bool, /// Formatted code differs from existing code (--check only). @@ -460,7 +473,6 @@ fn format_lines( report: &FormatReport, ) { let mut formatter = FormatLines::new(name, skipped_range, config); - formatter.check_license(text); formatter.iterate(text); if formatter.newline_count > 1 { @@ -480,11 +492,9 @@ struct FormatLines<'a> { cur_line: usize, newline_count: usize, errors: Vec, - issue_seeker: BadIssueSeeker, line_buffer: String, current_line_contains_string_literal: bool, format_line: bool, - allow_issue_seek: bool, config: &'a Config, } @@ -494,7 +504,6 @@ impl<'a> FormatLines<'a> { skipped_range: &'a [(usize, usize)], config: &'a Config, ) -> FormatLines<'a> { - let issue_seeker = BadIssueSeeker::new(config.report_todo(), config.report_fixme()); FormatLines { name, skipped_range, @@ -503,8 +512,6 @@ impl<'a> FormatLines<'a> { cur_line: 1, newline_count: 0, errors: vec![], - allow_issue_seek: !issue_seeker.is_disabled(), - issue_seeker, line_buffer: String::with_capacity(config.max_width() * 2), current_line_contains_string_literal: false, format_line: config.file_lines().contains_line(name, 1), @@ -512,20 +519,6 @@ impl<'a> FormatLines<'a> { } } - fn check_license(&mut self, text: &mut String) { - if let Some(ref license_template) = self.config.license_template { - if !license_template.is_match(text) { - self.errors.push(FormattingError { - line: self.cur_line, - kind: ErrorKind::LicenseCheck, - is_comment: false, - is_string: false, - line_buffer: String::new(), - }); - } - } - } - // Iterate over the chars in the file map. fn iterate(&mut self, text: &mut String) { for (kind, c) in CharClasses::new(text.chars()) { @@ -533,13 +526,6 @@ impl<'a> FormatLines<'a> { continue; } - if self.allow_issue_seek && self.format_line { - // Add warnings for bad todos/ fixmes - if let Some(issue) = self.issue_seeker.inspect(c) { - self.push_err(ErrorKind::BadIssue(issue), false, false); - } - } - if c == '\n' { self.new_line(kind); } else { diff --git a/src/tools/rustfmt/src/imports.rs b/src/tools/rustfmt/src/imports.rs index 02319809486..559ed3917db 100644 --- a/src/tools/rustfmt/src/imports.rs +++ b/src/tools/rustfmt/src/imports.rs @@ -2,6 +2,10 @@ use std::borrow::Cow; use std::cmp::Ordering; use std::fmt; +use core::hash::{Hash, Hasher}; + +use itertools::Itertools; + use rustc_ast::ast::{self, UseTreeKind}; use rustc_span::{ symbol::{self, sym}, @@ -10,6 +14,7 @@ use rustc_span::{ use crate::comment::combine_strs_with_missing_comments; use crate::config::lists::*; +use crate::config::ImportGranularity; use crate::config::{Edition, IndentStyle}; use crate::lists::{ definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator, @@ -86,7 +91,7 @@ impl<'a> FmtVisitor<'a> { // sorting. // FIXME we do a lot of allocation to make our own representation. -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone, Eq, Hash, PartialEq)] pub(crate) enum UseSegment { Ident(String, Option), Slf(Option), @@ -180,17 +185,36 @@ impl UseSegment { } }) } + + fn contains_comment(&self) -> bool { + if let UseSegment::List(list) = self { + list.iter().any(|subtree| subtree.contains_comment()) + } else { + false + } + } } -pub(crate) fn merge_use_trees(use_trees: Vec, merge_by: SharedPrefix) -> Vec { +pub(crate) fn normalize_use_trees_with_granularity( + use_trees: Vec, + import_granularity: ImportGranularity, +) -> Vec { + let merge_by = match import_granularity { + ImportGranularity::Item => return flatten_use_trees(use_trees, ImportGranularity::Item), + ImportGranularity::Preserve => return use_trees, + ImportGranularity::Crate => SharedPrefix::Crate, + ImportGranularity::Module => SharedPrefix::Module, + ImportGranularity::One => SharedPrefix::One, + }; + let mut result = Vec::with_capacity(use_trees.len()); for use_tree in use_trees { - if use_tree.has_comment() || use_tree.attrs.is_some() { + if use_tree.contains_comment() || use_tree.attrs.is_some() { result.push(use_tree); continue; } - for mut flattened in use_tree.flatten() { + for mut flattened in use_tree.flatten(import_granularity) { if let Some(tree) = result .iter_mut() .find(|tree| tree.share_prefix(&flattened, merge_by)) @@ -208,11 +232,17 @@ pub(crate) fn merge_use_trees(use_trees: Vec, merge_by: SharedPrefix) - result } -pub(crate) fn flatten_use_trees(use_trees: Vec) -> Vec { +fn flatten_use_trees( + use_trees: Vec, + import_granularity: ImportGranularity, +) -> Vec { + // Return non-sorted single occurance of the use-trees text string; + // order is by first occurance of the use-tree. use_trees .into_iter() - .flat_map(UseTree::flatten) + .flat_map(|tree| tree.flatten(import_granularity)) .map(UseTree::nest_trailing_self) + .unique() .collect() } @@ -541,6 +571,10 @@ impl UseTree { self.list_item.as_ref().map_or(false, ListItem::has_comment) } + fn contains_comment(&self) -> bool { + self.has_comment() || self.path.iter().any(|path| path.contains_comment()) + } + fn same_visibility(&self, other: &UseTree) -> bool { match (&self.visibility, &other.visibility) { ( @@ -567,6 +601,7 @@ impl UseTree { if self.path.is_empty() || other.path.is_empty() || self.attrs.is_some() + || self.contains_comment() || !self.same_visibility(other) { false @@ -581,8 +616,8 @@ impl UseTree { } } - fn flatten(self) -> Vec { - if self.path.is_empty() { + fn flatten(self, import_granularity: ImportGranularity) -> Vec { + if self.path.is_empty() || self.contains_comment() { return vec![self]; } match self.path.clone().last().unwrap() { @@ -595,7 +630,7 @@ impl UseTree { let prefix = &self.path[..self.path.len() - 1]; let mut result = vec![]; for nested_use_tree in list { - for flattend in &mut nested_use_tree.clone().flatten() { + for flattend in &mut nested_use_tree.clone().flatten(import_granularity) { let mut new_path = prefix.to_vec(); new_path.append(&mut flattend.path); result.push(UseTree { @@ -603,7 +638,11 @@ impl UseTree { span: self.span, list_item: None, visibility: self.visibility.clone(), - attrs: None, + // only retain attributes for `ImportGranularity::Item` + attrs: match import_granularity { + ImportGranularity::Item => self.attrs.clone(), + _ => None, + }, }); } } @@ -748,6 +787,12 @@ fn merge_use_trees_inner(trees: &mut Vec, use_tree: UseTree, merge_by: trees.sort(); } +impl Hash for UseTree { + fn hash(&self, state: &mut H) { + self.path.hash(state); + } +} + impl PartialOrd for UseSegment { fn partial_cmp(&self, other: &UseSegment) -> Option { Some(self.cmp(other)) @@ -951,7 +996,7 @@ impl Rewrite for UseTree { } #[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub(crate) enum SharedPrefix { +enum SharedPrefix { Crate, Module, One, @@ -1106,7 +1151,10 @@ mod test { macro_rules! test_merge { ($by:ident, [$($input:expr),* $(,)*], [$($output:expr),* $(,)*]) => { assert_eq!( - merge_use_trees(parse_use_trees!($($input,)*), SharedPrefix::$by), + normalize_use_trees_with_granularity( + parse_use_trees!($($input,)*), + ImportGranularity::$by, + ), parse_use_trees!($($output,)*), ); } @@ -1215,12 +1263,18 @@ mod test { #[test] fn test_flatten_use_trees() { assert_eq!( - flatten_use_trees(parse_use_trees!["foo::{a::{b, c}, d::e}"]), + flatten_use_trees( + parse_use_trees!["foo::{a::{b, c}, d::e}"], + ImportGranularity::Item + ), parse_use_trees!["foo::a::b", "foo::a::c", "foo::d::e"] ); assert_eq!( - flatten_use_trees(parse_use_trees!["foo::{self, a, b::{c, d}, e::*}"]), + flatten_use_trees( + parse_use_trees!["foo::{self, a, b::{c, d}, e::*}"], + ImportGranularity::Item + ), parse_use_trees![ "foo::{self}", "foo::a", @@ -1234,12 +1288,13 @@ mod test { #[test] fn test_use_tree_flatten() { assert_eq!( - parse_use_tree("a::b::{c, d, e, f}").flatten(), + parse_use_tree("a::b::{c, d, e, f}").flatten(ImportGranularity::Item), parse_use_trees!("a::b::c", "a::b::d", "a::b::e", "a::b::f",) ); assert_eq!( - parse_use_tree("a::b::{c::{d, e, f}, g, h::{i, j, k}}").flatten(), + parse_use_tree("a::b::{c::{d, e, f}, g, h::{i, j, k}}") + .flatten(ImportGranularity::Item), parse_use_trees![ "a::b::c::d", "a::b::c::e", diff --git a/src/tools/rustfmt/src/issues.rs b/src/tools/rustfmt/src/issues.rs deleted file mode 100644 index 33fb5522aea..00000000000 --- a/src/tools/rustfmt/src/issues.rs +++ /dev/null @@ -1,309 +0,0 @@ -// Objects for seeking through a char stream for occurrences of TODO and FIXME. -// Depending on the loaded configuration, may also check that these have an -// associated issue number. - -use std::fmt; - -use crate::config::ReportTactic; - -const TO_DO_CHARS: &[char] = &['t', 'o', 'd', 'o']; -const FIX_ME_CHARS: &[char] = &['f', 'i', 'x', 'm', 'e']; - -// Enabled implementation detail is here because it is -// irrelevant outside the issues module -fn is_enabled(report_tactic: ReportTactic) -> bool { - report_tactic != ReportTactic::Never -} - -#[derive(Clone, Copy)] -enum Seeking { - Issue { todo_idx: usize, fixme_idx: usize }, - Number { issue: Issue, part: NumberPart }, -} - -#[derive(Clone, Copy)] -enum NumberPart { - OpenParen, - Pound, - Number, - CloseParen, -} - -#[derive(PartialEq, Eq, Debug, Clone, Copy)] -pub struct Issue { - issue_type: IssueType, - // Indicates whether we're looking for issues with missing numbers, or - // all issues of this type. - missing_number: bool, -} - -impl fmt::Display for Issue { - fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - let msg = match self.issue_type { - IssueType::Todo => "TODO", - IssueType::Fixme => "FIXME", - }; - let details = if self.missing_number { - " without issue number" - } else { - "" - }; - - write!(fmt, "{}{}", msg, details) - } -} - -#[derive(PartialEq, Eq, Debug, Clone, Copy)] -enum IssueType { - Todo, - Fixme, -} - -enum IssueClassification { - Good, - Bad(Issue), - None, -} - -pub(crate) struct BadIssueSeeker { - state: Seeking, - report_todo: ReportTactic, - report_fixme: ReportTactic, -} - -impl BadIssueSeeker { - pub(crate) fn new(report_todo: ReportTactic, report_fixme: ReportTactic) -> BadIssueSeeker { - BadIssueSeeker { - state: Seeking::Issue { - todo_idx: 0, - fixme_idx: 0, - }, - report_todo, - report_fixme, - } - } - - pub(crate) fn is_disabled(&self) -> bool { - !is_enabled(self.report_todo) && !is_enabled(self.report_fixme) - } - - // Check whether or not the current char is conclusive evidence for an - // unnumbered TO-DO or FIX-ME. - pub(crate) fn inspect(&mut self, c: char) -> Option { - match self.state { - Seeking::Issue { - todo_idx, - fixme_idx, - } => { - self.state = self.inspect_issue(c, todo_idx, fixme_idx); - } - Seeking::Number { issue, part } => { - let result = self.inspect_number(c, issue, part); - - if let IssueClassification::None = result { - return None; - } - - self.state = Seeking::Issue { - todo_idx: 0, - fixme_idx: 0, - }; - - if let IssueClassification::Bad(issue) = result { - return Some(issue); - } - } - } - - None - } - - fn inspect_issue(&mut self, c: char, mut todo_idx: usize, mut fixme_idx: usize) -> Seeking { - if let Some(lower_case_c) = c.to_lowercase().next() { - if is_enabled(self.report_todo) && lower_case_c == TO_DO_CHARS[todo_idx] { - todo_idx += 1; - if todo_idx == TO_DO_CHARS.len() { - return Seeking::Number { - issue: Issue { - issue_type: IssueType::Todo, - missing_number: matches!(self.report_todo, ReportTactic::Unnumbered), - }, - part: NumberPart::OpenParen, - }; - } - fixme_idx = 0; - } else if is_enabled(self.report_fixme) && lower_case_c == FIX_ME_CHARS[fixme_idx] { - // Exploit the fact that the character sets of todo and fixme - // are disjoint by adding else. - fixme_idx += 1; - if fixme_idx == FIX_ME_CHARS.len() { - return Seeking::Number { - issue: Issue { - issue_type: IssueType::Fixme, - missing_number: matches!(self.report_fixme, ReportTactic::Unnumbered), - }, - part: NumberPart::OpenParen, - }; - } - todo_idx = 0; - } else { - todo_idx = 0; - fixme_idx = 0; - } - } - - Seeking::Issue { - todo_idx, - fixme_idx, - } - } - - fn inspect_number( - &mut self, - c: char, - issue: Issue, - mut part: NumberPart, - ) -> IssueClassification { - if !issue.missing_number || c == '\n' { - return IssueClassification::Bad(issue); - } else if c == ')' { - return if let NumberPart::CloseParen = part { - IssueClassification::Good - } else { - IssueClassification::Bad(issue) - }; - } - - match part { - NumberPart::OpenParen => { - if c != '(' { - return IssueClassification::Bad(issue); - } else { - part = NumberPart::Pound; - } - } - NumberPart::Pound => { - if c == '#' { - part = NumberPart::Number; - } - } - NumberPart::Number => { - if ('0'..='9').contains(&c) { - part = NumberPart::CloseParen; - } else { - return IssueClassification::Bad(issue); - } - } - NumberPart::CloseParen => {} - } - - self.state = Seeking::Number { part, issue }; - - IssueClassification::None - } -} - -#[test] -fn find_unnumbered_issue() { - fn check_fail(text: &str, failing_pos: usize) { - let mut seeker = BadIssueSeeker::new(ReportTactic::Unnumbered, ReportTactic::Unnumbered); - assert_eq!( - Some(failing_pos), - text.find(|c| seeker.inspect(c).is_some()) - ); - } - - fn check_pass(text: &str) { - let mut seeker = BadIssueSeeker::new(ReportTactic::Unnumbered, ReportTactic::Unnumbered); - assert_eq!(None, text.find(|c| seeker.inspect(c).is_some())); - } - - check_fail("TODO\n", 4); - check_pass(" TO FIX DOME\n"); - check_fail(" \n FIXME\n", 8); - check_fail("FIXME(\n", 6); - check_fail("FIXME(#\n", 7); - check_fail("FIXME(#1\n", 8); - check_fail("FIXME(#)1\n", 7); - check_pass("FIXME(#1222)\n"); - check_fail("FIXME(#12\n22)\n", 9); - check_pass("FIXME(@maintainer, #1222, hello)\n"); - check_fail("TODO(#22) FIXME\n", 15); -} - -#[test] -fn find_issue() { - fn is_bad_issue(text: &str, report_todo: ReportTactic, report_fixme: ReportTactic) -> bool { - let mut seeker = BadIssueSeeker::new(report_todo, report_fixme); - text.chars().any(|c| seeker.inspect(c).is_some()) - } - - assert!(is_bad_issue( - "TODO(@maintainer, #1222, hello)\n", - ReportTactic::Always, - ReportTactic::Never, - )); - - assert!(!is_bad_issue( - "TODO: no number\n", - ReportTactic::Never, - ReportTactic::Always, - )); - - assert!(!is_bad_issue( - "Todo: mixed case\n", - ReportTactic::Never, - ReportTactic::Always, - )); - - assert!(is_bad_issue( - "This is a FIXME(#1)\n", - ReportTactic::Never, - ReportTactic::Always, - )); - - assert!(is_bad_issue( - "This is a FixMe(#1) mixed case\n", - ReportTactic::Never, - ReportTactic::Always, - )); - - assert!(!is_bad_issue( - "bad FIXME\n", - ReportTactic::Always, - ReportTactic::Never, - )); -} - -#[test] -fn issue_type() { - let mut seeker = BadIssueSeeker::new(ReportTactic::Always, ReportTactic::Never); - let expected = Some(Issue { - issue_type: IssueType::Todo, - missing_number: false, - }); - - assert_eq!( - expected, - "TODO(#100): more awesomeness" - .chars() - .map(|c| seeker.inspect(c)) - .find(Option::is_some) - .unwrap() - ); - - let mut seeker = BadIssueSeeker::new(ReportTactic::Never, ReportTactic::Unnumbered); - let expected = Some(Issue { - issue_type: IssueType::Fixme, - missing_number: true, - }); - - assert_eq!( - expected, - "Test. FIXME: bad, bad, not good" - .chars() - .map(|c| seeker.inspect(c)) - .find(Option::is_some) - .unwrap() - ); -} diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs index 8816d7d2f1f..bab881f4b4e 100644 --- a/src/tools/rustfmt/src/items.rs +++ b/src/tools/rustfmt/src/items.rs @@ -1770,7 +1770,7 @@ pub(crate) fn rewrite_struct_field( .offset_left(overhead + spacing.len()) .and_then(|ty_shape| field.ty.rewrite(context, ty_shape)); if let Some(ref ty) = orig_ty { - if !ty.contains('\n') { + if !ty.contains('\n') && !contains_comment(context.snippet(missing_span)) { return Some(attr_prefix + &spacing + ty); } } diff --git a/src/tools/rustfmt/src/lib.rs b/src/tools/rustfmt/src/lib.rs index fae8080c02e..1d1ef525f23 100644 --- a/src/tools/rustfmt/src/lib.rs +++ b/src/tools/rustfmt/src/lib.rs @@ -40,7 +40,6 @@ use thiserror::Error; use crate::comment::LineClasses; use crate::emitter::Emitter; use crate::formatting::{FormatErrorMap, FormattingError, ReportedErrors, SourceFile}; -use crate::issues::Issue; use crate::modules::ModuleResolutionError; use crate::parse::parser::DirectoryOwnership; use crate::shape::Indent; @@ -70,7 +69,6 @@ mod format_report_formatter; pub(crate) mod formatting; mod ignore_path; mod imports; -mod issues; mod items; mod lists; mod macros; @@ -111,12 +109,6 @@ pub enum ErrorKind { /// Line ends in whitespace. #[error("left behind trailing whitespace")] TrailingWhitespace, - /// TODO or FIXME item without an issue number. - #[error("found {0}")] - BadIssue(Issue), - /// License check has failed. - #[error("license check failed")] - LicenseCheck, /// Used deprecated skip attribute. #[error("`rustfmt_skip` is deprecated; use `rustfmt::skip`")] DeprecatedAttr, @@ -237,11 +229,7 @@ impl FormatReport { ErrorKind::LostComment => { errs.has_unformatted_code_errors = true; } - ErrorKind::BadIssue(_) - | ErrorKind::LicenseCheck - | ErrorKind::DeprecatedAttr - | ErrorKind::BadAttr - | ErrorKind::VersionMismatch => { + ErrorKind::DeprecatedAttr | ErrorKind::BadAttr | ErrorKind::VersionMismatch => { errs.has_check_errors = true; } _ => {} diff --git a/src/tools/rustfmt/src/overflow.rs b/src/tools/rustfmt/src/overflow.rs index f115e7d0261..6bf8cd0c70b 100644 --- a/src/tools/rustfmt/src/overflow.rs +++ b/src/tools/rustfmt/src/overflow.rs @@ -32,7 +32,7 @@ use crate::utils::{count_newlines, extra_offset, first_line_width, last_line_wid /// Organized as a list of `(&str, usize)` tuples, giving the name of the macro and the number of /// arguments before the format string (none for `format!("format", ...)`, one for `assert!(result, /// "format", ...)`, two for `assert_eq!(left, right, "format", ...)`). -const SPECIAL_MACRO_WHITELIST: &[(&str, usize)] = &[ +const SPECIAL_CASE_MACROS: &[(&str, usize)] = &[ // format! like macros // From the Rust Standard Library. ("eprint!", 0), @@ -60,7 +60,7 @@ const SPECIAL_MACRO_WHITELIST: &[(&str, usize)] = &[ ("debug_assert_ne!", 2), ]; -const SPECIAL_ATTR_WHITELIST: &[(&str, usize)] = &[ +const SPECIAL_CASE_ATTR: &[(&str, usize)] = &[ // From the `failure` crate. ("fail", 0), ]; @@ -182,10 +182,10 @@ impl<'a> OverflowableItem<'a> { } } - fn whitelist(&self) -> &'static [(&'static str, usize)] { + fn special_cases(&self) -> &'static [(&'static str, usize)] { match self { - OverflowableItem::MacroArg(..) => SPECIAL_MACRO_WHITELIST, - OverflowableItem::NestedMetaItem(..) => SPECIAL_ATTR_WHITELIST, + OverflowableItem::MacroArg(..) => SPECIAL_CASE_MACROS, + OverflowableItem::NestedMetaItem(..) => SPECIAL_CASE_ATTR, _ => &[], } } @@ -770,7 +770,7 @@ pub(crate) fn maybe_get_args_offset( ) -> Option<(bool, usize)> { if let Some(&(_, num_args_before)) = args .get(0)? - .whitelist() + .special_cases() .iter() .find(|&&(s, _)| s == callee_str) { diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs index 4408e20747a..a0f71c2b8ba 100644 --- a/src/tools/rustfmt/src/parse/session.rs +++ b/src/tools/rustfmt/src/parse/session.rs @@ -170,7 +170,7 @@ impl ParseSess { /// * `relative` - If Some(symbol), the symbol name is a directory relative to the dir_path. /// If relative is Some, resolve the submodle at {dir_path}/{symbol}/{id}.rs /// or {dir_path}/{symbol}/{id}/mod.rs. if None, resolve the module at {dir_path}/{id}.rs. - /// * `dir_path` - Module resolution will occur relative to this direcotry. + /// * `dir_path` - Module resolution will occur relative to this directory. pub(crate) fn default_submod_path( &self, id: symbol::Ident, diff --git a/src/tools/rustfmt/src/reorder.rs b/src/tools/rustfmt/src/reorder.rs index 13bfc92507d..8ae297de25b 100644 --- a/src/tools/rustfmt/src/reorder.rs +++ b/src/tools/rustfmt/src/reorder.rs @@ -11,8 +11,8 @@ use std::cmp::{Ord, Ordering}; use rustc_ast::ast; use rustc_span::{symbol::sym, Span}; -use crate::config::{Config, GroupImportsTactic, ImportGranularity}; -use crate::imports::{flatten_use_trees, merge_use_trees, SharedPrefix, UseSegment, UseTree}; +use crate::config::{Config, GroupImportsTactic}; +use crate::imports::{normalize_use_trees_with_granularity, UseSegment, UseTree}; use crate::items::{is_mod_decl, rewrite_extern_crate, rewrite_mod}; use crate::lists::{itemize_list, write_list, ListFormatting, ListItem}; use crate::rewrite::RewriteContext; @@ -107,15 +107,10 @@ fn rewrite_reorderable_or_regroupable_items( for (item, list_item) in normalized_items.iter_mut().zip(list_items) { item.list_item = Some(list_item.clone()); } - normalized_items = match context.config.imports_granularity() { - ImportGranularity::Crate => merge_use_trees(normalized_items, SharedPrefix::Crate), - ImportGranularity::Module => { - merge_use_trees(normalized_items, SharedPrefix::Module) - } - ImportGranularity::Item => flatten_use_trees(normalized_items), - ImportGranularity::One => merge_use_trees(normalized_items, SharedPrefix::One), - ImportGranularity::Preserve => normalized_items, - }; + normalized_items = normalize_use_trees_with_granularity( + normalized_items, + context.config.imports_granularity(), + ); let mut regrouped_items = match context.config.group_imports() { GroupImportsTactic::Preserve | GroupImportsTactic::One => { diff --git a/src/tools/rustfmt/src/rewrite.rs b/src/tools/rustfmt/src/rewrite.rs index 4a3bd129d16..f97df70cc6a 100644 --- a/src/tools/rustfmt/src/rewrite.rs +++ b/src/tools/rustfmt/src/rewrite.rs @@ -12,6 +12,7 @@ use crate::shape::Shape; use crate::skip::SkipContext; use crate::visitor::SnippetProvider; use crate::FormatReport; +use rustc_data_structures::stable_map::FxHashMap; pub(crate) trait Rewrite { /// Rewrite self into shape. @@ -24,10 +25,22 @@ impl Rewrite for ptr::P { } } +#[derive(Clone, PartialEq, Eq, Hash)] +pub(crate) struct QueryId { + pub(crate) shape: Shape, + pub(crate) span: Span, +} + +// We use Option instead of HashMap, because in case of `None` +// the function clean the memoize map, but it doesn't clean when +// there is `Some(empty)`, so they are different. +pub(crate) type Memoize = Rc>>>>; + #[derive(Clone)] pub(crate) struct RewriteContext<'a> { pub(crate) parse_sess: &'a ParseSess, pub(crate) config: &'a Config, + pub(crate) memoize: Memoize, pub(crate) inside_macro: Rc>, // Force block indent style even if we are using visual indent style. pub(crate) use_block: Cell, diff --git a/src/tools/rustfmt/src/shape.rs b/src/tools/rustfmt/src/shape.rs index 4376fd12b52..b3f785a9470 100644 --- a/src/tools/rustfmt/src/shape.rs +++ b/src/tools/rustfmt/src/shape.rs @@ -4,7 +4,7 @@ use std::ops::{Add, Sub}; use crate::Config; -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub(crate) struct Indent { // Width of the block indent, in characters. Must be a multiple of // Config::tab_spaces. @@ -139,7 +139,7 @@ impl Sub for Indent { // 8096 is close enough to infinite for rustfmt. const INFINITE_SHAPE_WIDTH: usize = 8096; -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub(crate) struct Shape { pub(crate) width: usize, // The current indentation of code. diff --git a/src/tools/rustfmt/src/string.rs b/src/tools/rustfmt/src/string.rs index b65aa5b33b2..78b72a50cb2 100644 --- a/src/tools/rustfmt/src/string.rs +++ b/src/tools/rustfmt/src/string.rs @@ -315,20 +315,21 @@ fn break_string(max_width: usize, trim_end: bool, line_end: &str, input: &[&str] // Found a whitespace and what is on its left side is big enough. Some(index) if index >= MIN_STRING => break_at(index), // No whitespace found, try looking for a punctuation instead - _ => match input[0..max_width_index_in_input] - .iter() - .rposition(|grapheme| is_punctuation(grapheme)) + _ => match (0..max_width_index_in_input) + .rev() + .skip_while(|pos| !is_valid_linebreak(input, *pos)) + .next() { // Found a punctuation and what is on its left side is big enough. Some(index) if index >= MIN_STRING => break_at(index), // Either no boundary character was found to the left of `input[max_chars]`, or the line // got too small. We try searching for a boundary character to the right. - _ => match input[max_width_index_in_input..] - .iter() - .position(|grapheme| is_whitespace(grapheme) || is_punctuation(grapheme)) + _ => match (max_width_index_in_input..input.len()) + .skip_while(|pos| !is_valid_linebreak(input, *pos)) + .next() { // A boundary was found after the line limit - Some(index) => break_at(max_width_index_in_input + index), + Some(index) => break_at(index), // No boundary to the right, the input cannot be broken None => SnippetState::EndOfInput(input.concat()), }, @@ -336,6 +337,23 @@ fn break_string(max_width: usize, trim_end: bool, line_end: &str, input: &[&str] } } +fn is_valid_linebreak(input: &[&str], pos: usize) -> bool { + let is_whitespace = is_whitespace(input[pos]); + if is_whitespace { + return true; + } + let is_punctuation = is_punctuation(input[pos]); + if is_punctuation && !is_part_of_type(input, pos) { + return true; + } + false +} + +fn is_part_of_type(input: &[&str], pos: usize) -> bool { + input.get(pos..=pos + 1) == Some(&[":", ":"]) + || input.get(pos.saturating_sub(1)..=pos) == Some(&[":", ":"]) +} + fn is_new_line(grapheme: &str) -> bool { let bytes = grapheme.as_bytes(); bytes.starts_with(b"\n") || bytes.starts_with(b"\r\n") @@ -369,6 +387,19 @@ mod test { rewrite_string("eq_", &fmt, 2); } + #[test] + fn line_break_at_valid_points_test() { + let string = "[TheName](Dont::break::my::type::That::would::be::very::nice) break here"; + let graphemes = UnicodeSegmentation::graphemes(&*string, false).collect::>(); + assert_eq!( + break_string(20, false, "", &graphemes[..]), + SnippetState::LineEnd( + "[TheName](Dont::break::my::type::That::would::be::very::nice) ".to_string(), + 62 + ) + ); + } + #[test] fn should_break_on_whitespace() { let string = "Placerat felis. Mauris porta ante sagittis purus."; diff --git a/src/tools/rustfmt/src/test/mod.rs b/src/tools/rustfmt/src/test/mod.rs index ab966d4a360..6b5bc2b30dd 100644 --- a/src/tools/rustfmt/src/test/mod.rs +++ b/src/tools/rustfmt/src/test/mod.rs @@ -9,7 +9,7 @@ use std::process::{Command, Stdio}; use std::str::Chars; use std::thread; -use crate::config::{Color, Config, EmitMode, FileName, NewlineStyle, ReportTactic}; +use crate::config::{Color, Config, EmitMode, FileName, NewlineStyle}; use crate::formatting::{ReportedErrors, SourceFile}; use crate::rustfmt_diff::{make_diff, print_diff, DiffLine, Mismatch, ModifiedChunk, OutputWriter}; use crate::source_file; @@ -24,7 +24,7 @@ mod parser; const DIFF_CONTEXT_SIZE: usize = 3; // A list of files on which we want to skip testing. -const SKIP_FILE_WHITE_LIST: &[&str] = &[ +const FILE_SKIP_LIST: &[&str] = &[ // We want to make sure that the `skip_children` is correctly working, // so we do not want to test this file directly. "configs/skip_children/foo/mod.rs", @@ -90,7 +90,7 @@ where } fn is_file_skip(path: &Path) -> bool { - SKIP_FILE_WHITE_LIST + FILE_SKIP_LIST .iter() .any(|file_path| is_subpath(path, file_path)) } @@ -578,6 +578,30 @@ fn stdin_generated_files_issue_5172() { ); } +#[test] +fn stdin_handles_mod_inner_ignore_attr() { + // see https://github.com/rust-lang/rustfmt/issues/5368 + init_log(); + let input = String::from("#![rustfmt::skip]\n\nfn main() { }"); + let mut child = Command::new(rustfmt().to_str().unwrap()) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .expect("failed to execute child"); + + { + let stdin = child.stdin.as_mut().expect("failed to get stdin"); + stdin + .write_all(input.as_bytes()) + .expect("failed to write stdin"); + } + + let output = child.wait_with_output().expect("failed to wait on child"); + assert!(output.status.success()); + assert!(output.stderr.is_empty()); + assert_eq!(input, String::from_utf8(output.stdout).unwrap()); +} + #[test] fn format_lines_errors_are_reported() { init_log(); @@ -688,9 +712,6 @@ fn read_config(filename: &Path) -> Config { } } - // Don't generate warnings for to-do items. - config.set().report_todo(ReportTactic::Never); - config } @@ -957,12 +978,6 @@ fn rustfmt() -> PathBuf { // Chop off `deps`. me.pop(); - // If we run `cargo test --release`, we might only have a release build. - if cfg!(release) { - // `../release/` - me.pop(); - me.push("release"); - } me.push("rustfmt"); assert!( me.is_file() || me.with_extension("exe").is_file(), diff --git a/src/tools/rustfmt/src/visitor.rs b/src/tools/rustfmt/src/visitor.rs index 9a0e0752c12..3ff56d52f92 100644 --- a/src/tools/rustfmt/src/visitor.rs +++ b/src/tools/rustfmt/src/visitor.rs @@ -17,7 +17,7 @@ use crate::items::{ use crate::macros::{macro_style, rewrite_macro, rewrite_macro_def, MacroPosition}; use crate::modules::Module; use crate::parse::session::ParseSess; -use crate::rewrite::{Rewrite, RewriteContext}; +use crate::rewrite::{Memoize, Rewrite, RewriteContext}; use crate::shape::{Indent, Shape}; use crate::skip::{is_skip_attr, SkipContext}; use crate::source_map::{LineRangeUtils, SpanUtils}; @@ -71,6 +71,7 @@ impl SnippetProvider { pub(crate) struct FmtVisitor<'a> { parent_context: Option<&'a RewriteContext<'a>>, + pub(crate) memoize: Memoize, pub(crate) parse_sess: &'a ParseSess, pub(crate) buffer: String, pub(crate) last_pos: BytePos, @@ -758,6 +759,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { ctx.config, ctx.snippet_provider, ctx.report.clone(), + ctx.memoize.clone(), ); visitor.skip_context.update(ctx.skip_context.clone()); visitor.set_parent_context(ctx); @@ -769,10 +771,12 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { config: &'a Config, snippet_provider: &'a SnippetProvider, report: FormatReport, + memoize: Memoize, ) -> FmtVisitor<'a> { FmtVisitor { parent_context: None, parse_sess: parse_session, + memoize, buffer: String::with_capacity(snippet_provider.big_snippet.len() * 2), last_pos: BytePos(0), block_indent: Indent::empty(), @@ -995,6 +999,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { RewriteContext { parse_sess: self.parse_sess, config: self.config, + memoize: self.memoize.clone(), inside_macro: Rc::new(Cell::new(false)), use_block: Cell::new(false), is_if_else_block: Cell::new(false), diff --git a/src/tools/rustfmt/tests/config/issue-3802.toml b/src/tools/rustfmt/tests/config/issue-3802.toml deleted file mode 100644 index 74ee8b010dd..00000000000 --- a/src/tools/rustfmt/tests/config/issue-3802.toml +++ /dev/null @@ -1,2 +0,0 @@ -unstable_features = true -license_template_path = "" diff --git a/src/tools/rustfmt/tests/config/small_tabs.toml b/src/tools/rustfmt/tests/config/small_tabs.toml index 35c8fd86467..c3cfd34317a 100644 --- a/src/tools/rustfmt/tests/config/small_tabs.toml +++ b/src/tools/rustfmt/tests/config/small_tabs.toml @@ -6,7 +6,5 @@ brace_style = "SameLineWhere" fn_args_layout = "Tall" trailing_comma = "Vertical" indent_style = "Block" -report_todo = "Always" -report_fixme = "Never" reorder_imports = false format_strings = true diff --git a/src/tools/rustfmt/tests/license-template/lt.txt b/src/tools/rustfmt/tests/license-template/lt.txt deleted file mode 100644 index ea4390371a0..00000000000 --- a/src/tools/rustfmt/tests/license-template/lt.txt +++ /dev/null @@ -1,2 +0,0 @@ -// rustfmt-license_template_path: tests/license-template/lt.txt -// Copyright {\d+} The rustfmt developers. diff --git a/src/tools/rustfmt/tests/rustfmt/main.rs b/src/tools/rustfmt/tests/rustfmt/main.rs index 450051d2fec..4c6d52726f3 100644 --- a/src/tools/rustfmt/tests/rustfmt/main.rs +++ b/src/tools/rustfmt/tests/rustfmt/main.rs @@ -143,7 +143,7 @@ fn mod_resolution_error_relative_module_not_found() { let args = ["tests/mod-resolver/module-not-found/relative_module/lib.rs"]; let (_stdout, stderr) = rustfmt(&args); // The file `./a.rs` and directory `./a` both exist. - // Module resolution fails becuase we're unable to find `./a/b.rs` + // Module resolution fails because we're unable to find `./a/b.rs` #[cfg(not(windows))] assert!(stderr.contains("a/b.rs does not exist")); #[cfg(windows)] diff --git a/src/tools/rustfmt/tests/source/configs/group_imports/StdExternalCrate-non_consecutive.rs b/src/tools/rustfmt/tests/source/configs/group_imports/StdExternalCrate-non_consecutive.rs new file mode 100644 index 00000000000..f239a0efa08 --- /dev/null +++ b/src/tools/rustfmt/tests/source/configs/group_imports/StdExternalCrate-non_consecutive.rs @@ -0,0 +1,27 @@ +// rustfmt-group_imports: StdExternalCrate +use chrono::Utc; +use super::update::convert_publish_payload; + + + + + +use juniper::{FieldError, FieldResult}; + +use uuid::Uuid; +use alloc::alloc::Layout; + +extern crate uuid; + + + + + +use std::sync::Arc; + + +use broker::database::PooledConnection; + +use super::schema::{Context, Payload}; +use core::f32; +use crate::models::Event; diff --git a/src/tools/rustfmt/tests/source/imports-impl-only-use.rs b/src/tools/rustfmt/tests/source/imports/imports-impl-only-use.rs similarity index 100% rename from src/tools/rustfmt/tests/source/imports-impl-only-use.rs rename to src/tools/rustfmt/tests/source/imports/imports-impl-only-use.rs diff --git a/src/tools/rustfmt/tests/source/imports-reorder-lines-and-items.rs b/src/tools/rustfmt/tests/source/imports/imports-reorder-lines-and-items.rs similarity index 100% rename from src/tools/rustfmt/tests/source/imports-reorder-lines-and-items.rs rename to src/tools/rustfmt/tests/source/imports/imports-reorder-lines-and-items.rs diff --git a/src/tools/rustfmt/tests/source/imports-reorder-lines.rs b/src/tools/rustfmt/tests/source/imports/imports-reorder-lines.rs similarity index 100% rename from src/tools/rustfmt/tests/source/imports-reorder-lines.rs rename to src/tools/rustfmt/tests/source/imports/imports-reorder-lines.rs diff --git a/src/tools/rustfmt/tests/source/imports-reorder.rs b/src/tools/rustfmt/tests/source/imports/imports-reorder.rs similarity index 100% rename from src/tools/rustfmt/tests/source/imports-reorder.rs rename to src/tools/rustfmt/tests/source/imports/imports-reorder.rs diff --git a/src/tools/rustfmt/tests/source/imports.rs b/src/tools/rustfmt/tests/source/imports/imports.rs similarity index 100% rename from src/tools/rustfmt/tests/source/imports.rs rename to src/tools/rustfmt/tests/source/imports/imports.rs diff --git a/src/tools/rustfmt/tests/source/imports_block_indent.rs b/src/tools/rustfmt/tests/source/imports/imports_block_indent.rs similarity index 100% rename from src/tools/rustfmt/tests/source/imports_block_indent.rs rename to src/tools/rustfmt/tests/source/imports/imports_block_indent.rs diff --git a/src/tools/rustfmt/tests/source/imports_granularity_crate.rs b/src/tools/rustfmt/tests/source/imports/imports_granularity_crate.rs similarity index 57% rename from src/tools/rustfmt/tests/source/imports_granularity_crate.rs rename to src/tools/rustfmt/tests/source/imports/imports_granularity_crate.rs index d16681b01b5..f6f7761e82e 100644 --- a/src/tools/rustfmt/tests/source/imports_granularity_crate.rs +++ b/src/tools/rustfmt/tests/source/imports/imports_granularity_crate.rs @@ -35,3 +35,31 @@ use j::{a::{self}}; use {k::{a, b}, l::{a, b}}; use {k::{c, d}, l::{c, d}}; + +use b::{f::g, h::{i, j} /* After b::h group */}; +use b::e; +use b::{/* Before b::l group */ l::{self, m, n::o, p::*}, q}; +use b::d; +use b::r; // After b::r +use b::q::{self /* After b::q::self */}; +use b::u::{ + a, + b, +}; +use b::t::{ + // Before b::t::a + a, + b, +}; +use b::s::{ + a, + b, // After b::s::b +}; +use b::v::{ + // Before b::v::a + a, + // Before b::v::b + b, +}; +use b::t::{/* Before b::t::self */ self}; +use b::c; diff --git a/src/tools/rustfmt/tests/source/imports/imports_granularity_default-with-dups.rs b/src/tools/rustfmt/tests/source/imports/imports_granularity_default-with-dups.rs new file mode 100644 index 00000000000..cbb21a9f1b3 --- /dev/null +++ b/src/tools/rustfmt/tests/source/imports/imports_granularity_default-with-dups.rs @@ -0,0 +1,6 @@ +use crate::lexer; +use crate::lexer::tokens::TokenData; +use crate::lexer::{tokens::TokenData}; +use crate::lexer::self; +use crate::lexer::{self}; +use crate::lexer::{self, tokens::TokenData}; diff --git a/src/tools/rustfmt/tests/source/imports/imports_granularity_item-with-dups-StdExternalCrate-no-reorder.rs b/src/tools/rustfmt/tests/source/imports/imports_granularity_item-with-dups-StdExternalCrate-no-reorder.rs new file mode 100644 index 00000000000..e23705a884f --- /dev/null +++ b/src/tools/rustfmt/tests/source/imports/imports_granularity_item-with-dups-StdExternalCrate-no-reorder.rs @@ -0,0 +1,13 @@ +// rustfmt-imports_granularity: Item +// rustfmt-reorder_imports: false +// rustfmt-group_imports: StdExternalCrate + +use crate::lexer; +use crate::lexer; +use crate::lexer::tokens::TokenData; +use crate::lexer::{tokens::TokenData}; +use crate::lexer::self; +use crate::lexer; +use crate::lexer; +use crate::lexer::{self}; +use crate::lexer::{self, tokens::TokenData}; diff --git a/src/tools/rustfmt/tests/source/imports/imports_granularity_item-with-dups.rs b/src/tools/rustfmt/tests/source/imports/imports_granularity_item-with-dups.rs new file mode 100644 index 00000000000..3e9589c299f --- /dev/null +++ b/src/tools/rustfmt/tests/source/imports/imports_granularity_item-with-dups.rs @@ -0,0 +1,11 @@ +// rustfmt-imports_granularity: Item + +use crate::lexer; +use crate::lexer; +use crate::lexer::tokens::TokenData; +use crate::lexer::{tokens::TokenData}; +use crate::lexer::self; +use crate::lexer; +use crate::lexer; +use crate::lexer::{self}; +use crate::lexer::{self, tokens::TokenData}; diff --git a/src/tools/rustfmt/tests/source/imports/imports_granularity_item.rs b/src/tools/rustfmt/tests/source/imports/imports_granularity_item.rs new file mode 100644 index 00000000000..b82c0d33caf --- /dev/null +++ b/src/tools/rustfmt/tests/source/imports/imports_granularity_item.rs @@ -0,0 +1,34 @@ +// rustfmt-imports_granularity: Item + +use a::{b, c, d}; +use a::{f::g, h::{i, j}}; +use a::{l::{self, m, n::o, p::*}}; +use a::q::{self}; + +use b::{f::g, h::{i, j} /* After b::h group */}; +use b::e; +use b::{/* Before b::l group */ l::{self, m, n::o, p::*}, q}; +use b::d; +use b::r; // After b::r +use b::q::{self /* After b::q::self */}; +use b::u::{ + a, + b, +}; +use b::t::{ + // Before b::t::a + a, + b, +}; +use b::s::{ + a, + b, // After b::s::b +}; +use b::v::{ + // Before b::v::a + a, + // Before b::v::b + b, +}; +use b::t::{/* Before b::t::self */ self}; +use b::c; diff --git a/src/tools/rustfmt/tests/source/imports/imports_granularity_module.rs b/src/tools/rustfmt/tests/source/imports/imports_granularity_module.rs new file mode 100644 index 00000000000..c7f68cea6d4 --- /dev/null +++ b/src/tools/rustfmt/tests/source/imports/imports_granularity_module.rs @@ -0,0 +1,47 @@ +// rustfmt-imports_granularity: Module + +use a::{b::c, d::e}; +use a::{f, g::{h, i}}; +use a::{j::{self, k::{self, l}, m}, n::{o::p, q}}; +pub use a::{r::s, t}; +use b::{c::d, self}; + +#[cfg(test)] +use foo::{a::b, c::d}; +use foo::e; + +use bar::{ + // comment + a::b, + // more comment + c::d, + e::f, +}; + +use b::{f::g, h::{i, j} /* After b::h group */}; +use b::e; +use b::{/* Before b::l group */ l::{self, m, n::o, p::*}, q}; +use b::d; +use b::r; // After b::r +use b::q::{self /* After b::q::self */}; +use b::u::{ + a, + b, +}; +use b::t::{ + // Before b::t::a + a, + b, +}; +use b::s::{ + a, + b, // After b::s::b +}; +use b::v::{ + // Before b::v::a + a, + // Before b::v::b + b, +}; +use b::t::{/* Before b::t::self */ self}; +use b::c; diff --git a/src/tools/rustfmt/tests/source/imports_granularity_item.rs b/src/tools/rustfmt/tests/source/imports_granularity_item.rs deleted file mode 100644 index d0e94df66ae..00000000000 --- a/src/tools/rustfmt/tests/source/imports_granularity_item.rs +++ /dev/null @@ -1,6 +0,0 @@ -// rustfmt-imports_granularity: Item - -use a::{b, c, d}; -use a::{f::g, h::{i, j}}; -use a::{l::{self, m, n::o, p::*}}; -use a::q::{self}; diff --git a/src/tools/rustfmt/tests/source/imports_granularity_module.rs b/src/tools/rustfmt/tests/source/imports_granularity_module.rs deleted file mode 100644 index 2d7bb299aaa..00000000000 --- a/src/tools/rustfmt/tests/source/imports_granularity_module.rs +++ /dev/null @@ -1,19 +0,0 @@ -// rustfmt-imports_granularity: Module - -use a::{b::c, d::e}; -use a::{f, g::{h, i}}; -use a::{j::{self, k::{self, l}, m}, n::{o::p, q}}; -pub use a::{r::s, t}; -use b::{c::d, self}; - -#[cfg(test)] -use foo::{a::b, c::d}; -use foo::e; - -use bar::{ - // comment - a::b, - // more comment - c::d, - e::f, -}; diff --git a/src/tools/rustfmt/tests/source/imports_granularity_one.rs b/src/tools/rustfmt/tests/source/imports_granularity_one.rs index c21707df395..4d5a4795641 100644 --- a/src/tools/rustfmt/tests/source/imports_granularity_one.rs +++ b/src/tools/rustfmt/tests/source/imports_granularity_one.rs @@ -58,3 +58,31 @@ use a::{ }; use b as x; use a::ad::ada; + +use b::{f::g, h::{i, j} /* After b::h group */}; +use b::e; +use b::{/* Before b::l group */ l::{self, m, n::o, p::*}, q}; +use b::d; +use b::r; // After b::r +use b::q::{self /* After b::q::self */}; +use b::u::{ + a, + b, +}; +use b::t::{ + // Before b::t::a + a, + b, +}; +use b::s::{ + a, + b, // After b::s::b +}; +use b::v::{ + // Before b::v::a + a, + // Before b::v::b + b, +}; +use b::t::{/* Before b::t::self */ self}; +use b::c; diff --git a/src/tools/rustfmt/tests/source/issue-5030.rs b/src/tools/rustfmt/tests/source/issue-5030.rs new file mode 100644 index 00000000000..08ffaac7d1d --- /dev/null +++ b/src/tools/rustfmt/tests/source/issue-5030.rs @@ -0,0 +1,22 @@ +// rustfmt-imports_granularity: Item +// rustfmt-group_imports: One + +// Confirm that attributes are duplicated to all items in the use statement +#[cfg(feature = "foo")] +use std::collections::{ + HashMap, + HashSet, +}; + +// Separate the imports below from the ones above +const A: usize = 0; + +// Copying attrs works with import grouping as well +#[cfg(feature = "foo")] +use std::collections::{ + HashMap, + HashSet, +}; + +#[cfg(feature = "spam")] +use qux::{bar, baz}; diff --git a/src/tools/rustfmt/tests/source/issue-5260.rs b/src/tools/rustfmt/tests/source/issue-5260.rs new file mode 100644 index 00000000000..c0606817290 --- /dev/null +++ b/src/tools/rustfmt/tests/source/issue-5260.rs @@ -0,0 +1,14 @@ +// rustfmt-wrap_comments: true + +/// [MyType](VeryLongPathToMyType::NoLineBreak::Here::Okay::ThatWouldBeNice::Thanks) +fn documented_with_longtype() { + // # We're using a long type link, rustfmt should not break line + // on the type when `wrap_comments = true` +} + +/// VeryLongPathToMyType::JustMyType::But::VeryVery::Long::NoLineBreak::Here::Okay::ThatWouldBeNice::Thanks +fn documented_with_verylongtype() { + // # We're using a long type link, rustfmt should not break line + // on the type when `wrap_comments = true` +} + diff --git a/src/tools/rustfmt/tests/source/license-templates/empty_license_path.rs b/src/tools/rustfmt/tests/source/license-templates/empty_license_path.rs deleted file mode 100644 index d3a91e4231d..00000000000 --- a/src/tools/rustfmt/tests/source/license-templates/empty_license_path.rs +++ /dev/null @@ -1,5 +0,0 @@ -// rustfmt-config: issue-3802.toml - -fn main() { -println!("Hello world!"); -} diff --git a/src/tools/rustfmt/tests/source/license-templates/license.rs b/src/tools/rustfmt/tests/source/license-templates/license.rs deleted file mode 100644 index 6816011c60d..00000000000 --- a/src/tools/rustfmt/tests/source/license-templates/license.rs +++ /dev/null @@ -1,6 +0,0 @@ -// rustfmt-license_template_path: tests/license-template/lt.txt -// Copyright 2019 The rustfmt developers. - -fn main() { -println!("Hello world!"); -} diff --git a/src/tools/rustfmt/tests/source/performance/issue-4476.rs b/src/tools/rustfmt/tests/source/performance/issue-4476.rs new file mode 100644 index 00000000000..8da3f19b62d --- /dev/null +++ b/src/tools/rustfmt/tests/source/performance/issue-4476.rs @@ -0,0 +1,638 @@ +use super::SemverParser; + +#[allow(dead_code, non_camel_case_types)] +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum Rule { + EOI, + range_set, + logical_or, + range, + empty, + hyphen, + simple, + primitive, + primitive_op, + partial, + xr, + xr_op, + nr, + tilde, + caret, + qualifier, + parts, + part, + space, +} +#[allow(clippy::all)] +impl ::pest::Parser for SemverParser { + fn parse<'i>( + rule: Rule, + input: &'i str, + ) -> ::std::result::Result<::pest::iterators::Pairs<'i, Rule>, ::pest::error::Error> { + mod rules { + pub mod hidden { + use super::super::Rule; + #[inline] + #[allow(dead_code, non_snake_case, unused_variables)] + pub fn skip( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + Ok(state) + } + } + pub mod visible { + use super::super::Rule; + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn range_set( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::range_set, |state| { + state.sequence(|state| { + self::SOI(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::range(state)) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + state + .sequence(|state| { + self::logical_or(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::range(state)) + }) + .and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| { + state.sequence(|state| { + self::logical_or(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::range(state)) + }) + }) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::EOI(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn logical_or( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::logical_or, |state| { + state.sequence(|state| { + state + .sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| state.match_string("||")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn range( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::range, |state| { + self::hyphen(state) + .or_else(|state| { + state.sequence(|state| { + self::simple(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + state + .sequence(|state| { + state + .optional(|state| state.match_string(",")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + self::space(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::simple(state)) + }) + .and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| { + state.sequence(|state| { + state + .optional(|state| state.match_string(",")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + self::space(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::simple(state)) + }) + }) + }) + }) + }) + }) + }) + }) + }) + }) + .or_else(|state| self::empty(state)) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn empty( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::empty, |state| state.match_string("")) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn hyphen( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::hyphen, |state| { + state.sequence(|state| { + self::partial(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + self::space(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| state.match_string("-")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + self::space(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::partial(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn simple( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::simple, |state| { + self::primitive(state) + .or_else(|state| self::partial(state)) + .or_else(|state| self::tilde(state)) + .or_else(|state| self::caret(state)) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn primitive( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::primitive, |state| { + state.sequence(|state| { + self::primitive_op(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::partial(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn primitive_op( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::primitive_op, |state| { + state + .match_string("<=") + .or_else(|state| state.match_string(">=")) + .or_else(|state| state.match_string(">")) + .or_else(|state| state.match_string("<")) + .or_else(|state| state.match_string("=")) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn partial( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::partial, |state| { + state.sequence(|state| { + self::xr(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.optional(|state| { + state.sequence(|state| { + state + .match_string(".") + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::xr(state)) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.optional(|state| { + state.sequence(|state| { + state + .match_string(".") + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::xr(state)) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| state.optional(|state| self::qualifier(state))) + }) + }) + }) + }) + }) + }) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn xr( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::xr, |state| { + self::xr_op(state).or_else(|state| self::nr(state)) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn xr_op( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::xr_op, |state| { + state + .match_string("x") + .or_else(|state| state.match_string("X")) + .or_else(|state| state.match_string("*")) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn nr( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::nr, |state| { + state.match_string("0").or_else(|state| { + state.sequence(|state| { + state + .match_range('1'..'9') + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + state.match_range('0'..'9').and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| state.match_range('0'..'9')) + }) + }) + }) + }) + }) + }) + }) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn tilde( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::tilde, |state| { + state.sequence(|state| { + state + .match_string("~>") + .or_else(|state| state.match_string("~")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::partial(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn caret( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::caret, |state| { + state.sequence(|state| { + state + .match_string("^") + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::partial(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn qualifier( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::qualifier, |state| { + state.sequence(|state| { + state + .match_string("-") + .or_else(|state| state.match_string("+")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::parts(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn parts( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::parts, |state| { + state.sequence(|state| { + self::part(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + state + .sequence(|state| { + state + .match_string(".") + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::part(state)) + }) + .and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| { + state.sequence(|state| { + state + .match_string(".") + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::part(state)) + }) + }) + }) + }) + }) + }) + }) + }) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn part( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::part, |state| { + self::nr(state).or_else(|state| { + state.sequence(|state| { + state + .match_string("-") + .or_else(|state| state.match_range('0'..'9')) + .or_else(|state| state.match_range('A'..'Z')) + .or_else(|state| state.match_range('a'..'z')) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + state + .match_string("-") + .or_else(|state| state.match_range('0'..'9')) + .or_else(|state| state.match_range('A'..'Z')) + .or_else(|state| state.match_range('a'..'z')) + .and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then(|state| { + state + .match_string("-") + .or_else(|state| state.match_range('0'..'9')) + .or_else(|state| state.match_range('A'..'Z')) + .or_else(|state| state.match_range('a'..'z')) + }) + }) + }) + }) + }) + }) + }) + }) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn space( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state + .match_string(" ") + .or_else(|state| state.match_string("\t")) + } + #[inline] + #[allow(dead_code, non_snake_case, unused_variables)] + pub fn EOI( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::EOI, |state| state.end_of_input()) + } + #[inline] + #[allow(dead_code, non_snake_case, unused_variables)] + pub fn SOI( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.start_of_input() + } + } + pub use self::visible::*; + } + ::pest::state(input, |state| match rule { + Rule::range_set => rules::range_set(state), + Rule::logical_or => rules::logical_or(state), + Rule::range => rules::range(state), + Rule::empty => rules::empty(state), + Rule::hyphen => rules::hyphen(state), + Rule::simple => rules::simple(state), + Rule::primitive => rules::primitive(state), + Rule::primitive_op => rules::primitive_op(state), + Rule::partial => rules::partial(state), + Rule::xr => rules::xr(state), + Rule::xr_op => rules::xr_op(state), + Rule::nr => rules::nr(state), + Rule::tilde => rules::tilde(state), + Rule::caret => rules::caret(state), + Rule::qualifier => rules::qualifier(state), + Rule::parts => rules::parts(state), + Rule::part => rules::part(state), + Rule::space => rules::space(state), + Rule::EOI => rules::EOI(state), + }) + } +} \ No newline at end of file diff --git a/src/tools/rustfmt/tests/source/performance/issue-5128.rs b/src/tools/rustfmt/tests/source/performance/issue-5128.rs new file mode 100644 index 00000000000..3adce49601c --- /dev/null +++ b/src/tools/rustfmt/tests/source/performance/issue-5128.rs @@ -0,0 +1,5127 @@ + +fn takes_a_long_time_to_rustfmt() { + let inner_cte = vec![Node { + node: Some(node::Node::CommonTableExpr(Box::new(CommonTableExpr { + ctename: String::from("ranked_by_age_within_key"), + aliascolnames: vec![], + ctematerialized: CteMaterialize::Default as i32, + ctequery: Some(Box::new(Node { + node: Some(node::Node::SelectStmt(Box::new(SelectStmt { + distinct_clause: vec![], + into_clause: None, + target_list: vec![ + Node { + node: Some(node::Node::ResTarget(Box::new(ResTarget { + name: String::from(""), + indirection: vec![], + val: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::AStar(AStar{})) + }], + location: 80 + })) + })), + location: 80 + }))) + }, + Node { + node: Some(node::Node::ResTarget(Box::new(ResTarget { + name: String::from("rank_in_key"), + indirection: vec![], + val: Some(Box::new(Node { + node: Some(node::Node::FuncCall(Box::new(FuncCall { + funcname: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("row_number") + })) + }], + args: vec![], + agg_order: vec![], + agg_filter: None, + agg_within_group: false, + agg_star: false, + agg_distinct: false, + func_variadic: false, + over: Some(Box::new(WindowDef { + name: String::from(""), + refname: String::from(""), + partition_clause: vec![ + Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("synthetic_key") + })) + }], location: 123 + })) + }], order_clause: vec![Node { + node: Some(node::Node::SortBy(Box::new(SortBy { + node: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("logical_timestamp") + })) + }], location: 156 + })) + })), + sortby_dir: SortByDir::SortbyDesc as i32, + sortby_nulls: SortByNulls::SortbyNullsDefault as i32, + use_op: vec![], + location: -1 + }))) + }], frame_options: 1058, start_offset: None, end_offset: None, location: 109 + })), + location: 91 + }))) + })), + location: 91 + }))) + }], + from_clause: vec![Node { + node: Some(node::Node::RangeVar(RangeVar { + catalogname: String::from(""), schemaname: String::from("_supertables"), relname: String::from("9999-9999-9999"), inh: true, relpersistence: String::from("p"), alias: None, location: 206 + })) + }], + where_clause: Some(Box::new(Node { + node: Some(node::Node::AExpr(Box::new(AExpr { + kind: AExprKind::AexprOp as i32, + name: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("<=") + })) + }], + lexpr: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("logical_timestamp") + })) + }], + location: 250 + })) + })), + rexpr: Some(Box::new(Node { + node: Some(node::Node::AConst(Box::new(AConst { + val: Some(Box::new(Node { + node: Some(node::Node::Integer(Integer { + ival: 9000 + })) + })), + location: 271 + }))) + })), + location: 268 + }))) + })), + group_clause: vec![], + having_clause: None, + window_clause: vec![], + values_lists: vec![], + sort_clause: vec![], + limit_offset: None, + limit_count: None, + limit_option: LimitOption::Default as i32, + locking_clause: vec![], + with_clause: None, + op: SetOperation::SetopNone as i32, + all: false, + larg: None, + rarg: None + }))), + })), + location: 29, + cterecursive: false, + cterefcount: 0, + ctecolnames: vec![], + ctecoltypes: vec![], + ctecoltypmods: vec![], + ctecolcollations: vec![], + }))), + }]; + let outer_cte = vec![Node { + node: Some(node::Node::CommonTableExpr(Box::new(CommonTableExpr { + ctename: String::from("table_name"), + aliascolnames: vec![], + ctematerialized: CteMaterialize::Default as i32, + ctequery: Some(Box::new(Node { + node: Some(node::Node::SelectStmt(Box::new(SelectStmt { + distinct_clause: vec![], + into_clause: None, + target_list: vec![ + Node { + node: Some(node::Node::ResTarget(Box::new(ResTarget { + name: String::from("column1"), + indirection: vec![], + val: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("c1"), + })), + }], + location: 301, + })), + })), + location: 301, + }))), + }, + Node { + node: Some(node::Node::ResTarget(Box::new(ResTarget { + name: String::from("column2"), + indirection: vec![], + val: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("c2"), + })), + }], + location: 324, + })), + })), + location: 324, + }))), + }, + ], + from_clause: vec![Node { + node: Some(node::Node::RangeVar(RangeVar { + catalogname: String::from(""), + schemaname: String::from(""), + relname: String::from("ranked_by_age_within_key"), + inh: true, + relpersistence: String::from("p"), + alias: None, + location: 347, + })), + }], + where_clause: Some(Box::new(Node { + node: Some(node::Node::BoolExpr(Box::new(BoolExpr { + xpr: None, + boolop: BoolExprType::AndExpr as i32, + args: vec![ + Node { + node: Some(node::Node::AExpr(Box::new(AExpr { + kind: AExprKind::AexprOp as i32, + name: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("="), + })), + }], + lexpr: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String( + String2 { + str: String::from("rank_in_key"), + }, + )), + }], + location: 382, + })), + })), + rexpr: Some(Box::new(Node { + node: Some(node::Node::AConst(Box::new(AConst { + val: Some(Box::new(Node { + node: Some(node::Node::Integer( + Integer { ival: 1 }, + )), + })), + location: 396, + }))), + })), + location: 394, + }))), + }, + Node { + node: Some(node::Node::AExpr(Box::new(AExpr { + kind: AExprKind::AexprOp as i32, + name: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("="), + })), + }], + lexpr: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String( + String2 { + str: String::from("is_deleted"), + }, + )), + }], + location: 402, + })), + })), + rexpr: Some(Box::new(Node { + node: Some(node::Node::TypeCast(Box::new( + TypeCast { + arg: Some(Box::new(Node { + node: Some(node::Node::AConst( + Box::new(AConst { + val: Some(Box::new(Node { + node: Some( + node::Node::String( + String2 { + str: + String::from( + "f", + ), + }, + ), + ), + })), + location: 415, + }), + )), + })), + type_name: Some(TypeName { + names: vec![ + Node { + node: Some(node::Node::String( + String2 { + str: String::from( + "pg_catalog", + ), + }, + )), + }, + Node { + node: Some(node::Node::String( + String2 { + str: String::from( + "bool", + ), + }, + )), + }, + ], + type_oid: 0, + setof: false, + pct_type: false, + typmods: vec![], + typemod: -1, + array_bounds: vec![], + location: -1, + }), + location: -1, + }, + ))), + })), + location: 413, + }))), + }, + ], + location: 398, + }))), + })), + group_clause: vec![], + having_clause: None, + window_clause: vec![], + values_lists: vec![], + sort_clause: vec![], + limit_offset: None, + limit_count: None, + limit_option: LimitOption::Default as i32, + locking_clause: vec![], + with_clause: Some(WithClause { + ctes: inner_cte, + recursive: false, + location: 24, + }), + op: SetOperation::SetopNone as i32, + all: false, + larg: None, + rarg: None, + }))), + })), + location: 5, + cterecursive: false, + cterefcount: 0, + ctecolnames: vec![], + ctecoltypes: vec![], + ctecoltypmods: vec![], + ctecolcollations: vec![], + }))), + }]; + let expected_result = ParseResult { + version: 130003, + stmts: vec![RawStmt { + stmt: Some(Box::new(Node { + node: Some(node::Node::SelectStmt(Box::new(SelectStmt { + distinct_clause: vec![], + into_clause: None, + + target_list: vec![Node { + node: Some(node::Node::ResTarget(Box::new(ResTarget { + name: String::from(""), + indirection: vec![], + val: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("column1"), + })), + }], + location: 430, + })), + })), + location: 430, + }))), + }], + from_clause: vec![Node { + node: Some(node::Node::RangeVar(RangeVar { + catalogname: String::from(""), + schemaname: String::from(""), + relname: String::from("table_name"), + inh: true, + relpersistence: String::from("p"), + alias: None, + location: 443, + })), + }], + where_clause: Some(Box::new(Node { + node: Some(node::Node::AExpr(Box::new(AExpr { + kind: AExprKind::AexprOp as i32, + name: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from(">"), + })), + }], + lexpr: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("column2"), + })), + }], + location: 460, + })), + })), + rexpr: Some(Box::new(Node { + node: Some(node::Node::AConst(Box::new(AConst { + val: Some(Box::new(Node { + node: Some(node::Node::Integer(Integer { + ival: 9000, + })), + })), + location: 470, + }))), + })), + location: 468, + }))), + })), + group_clause: vec![], + having_clause: None, + window_clause: vec![], + values_lists: vec![], + sort_clause: vec![], + limit_offset: None, + limit_count: None, + limit_option: LimitOption::Default as i32, + locking_clause: vec![], + with_clause: Some(WithClause { + ctes: outer_cte, + recursive: false, + location: 0, + }), + op: SetOperation::SetopNone as i32, + all: false, + larg: None, + rarg: None, + }))), + })), + stmt_location: 0, + stmt_len: 0, + }], + }; + +} +#[derive(Clone, PartialEq)] +pub struct ParseResult { + + pub version: i32, + + pub stmts: Vec, +} +#[derive(Clone, PartialEq)] +pub struct ScanResult { + + pub version: i32, + + pub tokens: Vec, +} +#[derive(Clone, PartialEq)] +pub struct Node { + pub node: ::core::option::Option, +} +/// Nested message and enum types in `Node`. +pub mod node { + #[derive(Clone, PartialEq)] + pub enum Node { + + Alias(super::Alias), + + RangeVar(super::RangeVar), + + TableFunc(Box), + + Expr(super::Expr), + + Var(Box), + + Param(Box), + + Aggref(Box), + + GroupingFunc(Box), + + WindowFunc(Box), + + SubscriptingRef(Box), + + FuncExpr(Box), + + NamedArgExpr(Box), + + OpExpr(Box), + + DistinctExpr(Box), + + NullIfExpr(Box), + + ScalarArrayOpExpr(Box), + + BoolExpr(Box), + + SubLink(Box), + + SubPlan(Box), + + AlternativeSubPlan(Box), + + FieldSelect(Box), + + FieldStore(Box), + + RelabelType(Box), + + CoerceViaIo(Box), + + ArrayCoerceExpr(Box), + + ConvertRowtypeExpr(Box), + + CollateExpr(Box), + + CaseExpr(Box), + + CaseWhen(Box), + + CaseTestExpr(Box), + + ArrayExpr(Box), + + RowExpr(Box), + + RowCompareExpr(Box), + + CoalesceExpr(Box), + + MinMaxExpr(Box), + + SqlvalueFunction(Box), + + XmlExpr(Box), + + NullTest(Box), + + BooleanTest(Box), + + CoerceToDomain(Box), + + CoerceToDomainValue(Box), + + SetToDefault(Box), + + CurrentOfExpr(Box), + + NextValueExpr(Box), + + InferenceElem(Box), + + TargetEntry(Box), + + RangeTblRef(super::RangeTblRef), + + JoinExpr(Box), + + FromExpr(Box), + + OnConflictExpr(Box), + + IntoClause(Box), + + RawStmt(Box), + + Query(Box), + + InsertStmt(Box), + + DeleteStmt(Box), + + UpdateStmt(Box), + + SelectStmt(Box), + + AlterTableStmt(super::AlterTableStmt), + + AlterTableCmd(Box), + + AlterDomainStmt(Box), + + SetOperationStmt(Box), + + GrantStmt(super::GrantStmt), + + GrantRoleStmt(super::GrantRoleStmt), + + AlterDefaultPrivilegesStmt(super::AlterDefaultPrivilegesStmt), + + ClosePortalStmt(super::ClosePortalStmt), + + ClusterStmt(super::ClusterStmt), + + CopyStmt(Box), + + CreateStmt(super::CreateStmt), + + DefineStmt(super::DefineStmt), + + DropStmt(super::DropStmt), + + TruncateStmt(super::TruncateStmt), + + CommentStmt(Box), + + FetchStmt(super::FetchStmt), + + IndexStmt(Box), + + CreateFunctionStmt(super::CreateFunctionStmt), + + AlterFunctionStmt(super::AlterFunctionStmt), + + DoStmt(super::DoStmt), + + RenameStmt(Box), + + RuleStmt(Box), + + NotifyStmt(super::NotifyStmt), + + ListenStmt(super::ListenStmt), + + UnlistenStmt(super::UnlistenStmt), + + TransactionStmt(super::TransactionStmt), + + ViewStmt(Box), + + LoadStmt(super::LoadStmt), + + CreateDomainStmt(Box), + + CreatedbStmt(super::CreatedbStmt), + + DropdbStmt(super::DropdbStmt), + + VacuumStmt(super::VacuumStmt), + + ExplainStmt(Box), + + CreateTableAsStmt(Box), + + CreateSeqStmt(super::CreateSeqStmt), + + AlterSeqStmt(super::AlterSeqStmt), + + VariableSetStmt(super::VariableSetStmt), + + VariableShowStmt(super::VariableShowStmt), + + DiscardStmt(super::DiscardStmt), + + CreateTrigStmt(Box), + + CreatePlangStmt(super::CreatePLangStmt), + + CreateRoleStmt(super::CreateRoleStmt), + + AlterRoleStmt(super::AlterRoleStmt), + + DropRoleStmt(super::DropRoleStmt), + + LockStmt(super::LockStmt), + + ConstraintsSetStmt(super::ConstraintsSetStmt), + + ReindexStmt(super::ReindexStmt), + + CheckPointStmt(super::CheckPointStmt), + + CreateSchemaStmt(super::CreateSchemaStmt), + + AlterDatabaseStmt(super::AlterDatabaseStmt), + + AlterDatabaseSetStmt(super::AlterDatabaseSetStmt), + + AlterRoleSetStmt(super::AlterRoleSetStmt), + + CreateConversionStmt(super::CreateConversionStmt), + + CreateCastStmt(super::CreateCastStmt), + + CreateOpClassStmt(super::CreateOpClassStmt), + + CreateOpFamilyStmt(super::CreateOpFamilyStmt), + + AlterOpFamilyStmt(super::AlterOpFamilyStmt), + + PrepareStmt(Box), + + ExecuteStmt(super::ExecuteStmt), + + DeallocateStmt(super::DeallocateStmt), + + DeclareCursorStmt(Box), + + CreateTableSpaceStmt(super::CreateTableSpaceStmt), + + DropTableSpaceStmt(super::DropTableSpaceStmt), + + AlterObjectDependsStmt(Box), + + AlterObjectSchemaStmt(Box), + + AlterOwnerStmt(Box), + + AlterOperatorStmt(super::AlterOperatorStmt), + + AlterTypeStmt(super::AlterTypeStmt), + + DropOwnedStmt(super::DropOwnedStmt), + + ReassignOwnedStmt(super::ReassignOwnedStmt), + + CompositeTypeStmt(super::CompositeTypeStmt), + + CreateEnumStmt(super::CreateEnumStmt), + + CreateRangeStmt(super::CreateRangeStmt), + + AlterEnumStmt(super::AlterEnumStmt), + + AlterTsdictionaryStmt(super::AlterTsDictionaryStmt), + + AlterTsconfigurationStmt(super::AlterTsConfigurationStmt), + + CreateFdwStmt(super::CreateFdwStmt), + + AlterFdwStmt(super::AlterFdwStmt), + + CreateForeignServerStmt(super::CreateForeignServerStmt), + + AlterForeignServerStmt(super::AlterForeignServerStmt), + + CreateUserMappingStmt(super::CreateUserMappingStmt), + + AlterUserMappingStmt(super::AlterUserMappingStmt), + + DropUserMappingStmt(super::DropUserMappingStmt), + + AlterTableSpaceOptionsStmt(super::AlterTableSpaceOptionsStmt), + + AlterTableMoveAllStmt(super::AlterTableMoveAllStmt), + + SecLabelStmt(Box), + + CreateForeignTableStmt(super::CreateForeignTableStmt), + + ImportForeignSchemaStmt(super::ImportForeignSchemaStmt), + + CreateExtensionStmt(super::CreateExtensionStmt), + + AlterExtensionStmt(super::AlterExtensionStmt), + + AlterExtensionContentsStmt(Box), + + CreateEventTrigStmt(super::CreateEventTrigStmt), + + AlterEventTrigStmt(super::AlterEventTrigStmt), + + RefreshMatViewStmt(super::RefreshMatViewStmt), + + ReplicaIdentityStmt(super::ReplicaIdentityStmt), + + AlterSystemStmt(super::AlterSystemStmt), + + CreatePolicyStmt(Box), + + AlterPolicyStmt(Box), + + CreateTransformStmt(super::CreateTransformStmt), + + CreateAmStmt(super::CreateAmStmt), + + CreatePublicationStmt(super::CreatePublicationStmt), + + AlterPublicationStmt(super::AlterPublicationStmt), + + CreateSubscriptionStmt(super::CreateSubscriptionStmt), + + AlterSubscriptionStmt(super::AlterSubscriptionStmt), + + DropSubscriptionStmt(super::DropSubscriptionStmt), + + CreateStatsStmt(super::CreateStatsStmt), + + AlterCollationStmt(super::AlterCollationStmt), + + CallStmt(Box), + + AlterStatsStmt(super::AlterStatsStmt), + + AExpr(Box), + + ColumnRef(super::ColumnRef), + + ParamRef(super::ParamRef), + + AConst(Box), + + FuncCall(Box), + + AStar(super::AStar), + + AIndices(Box), + + AIndirection(Box), + + AArrayExpr(super::AArrayExpr), + + ResTarget(Box), + + MultiAssignRef(Box), + + TypeCast(Box), + + CollateClause(Box), + + SortBy(Box), + + WindowDef(Box), + + RangeSubselect(Box), + + RangeFunction(super::RangeFunction), + + RangeTableSample(Box), + + RangeTableFunc(Box), + + RangeTableFuncCol(Box), + + TypeName(super::TypeName), + + ColumnDef(Box), + + IndexElem(Box), + + Constraint(Box), + + DefElem(Box), + + RangeTblEntry(Box), + + RangeTblFunction(Box), + + TableSampleClause(Box), + + WithCheckOption(Box), + + SortGroupClause(super::SortGroupClause), + + GroupingSet(super::GroupingSet), + + WindowClause(Box), + + ObjectWithArgs(super::ObjectWithArgs), + + AccessPriv(super::AccessPriv), + + CreateOpClassItem(super::CreateOpClassItem), + + TableLikeClause(super::TableLikeClause), + + FunctionParameter(Box), + + LockingClause(super::LockingClause), + + RowMarkClause(super::RowMarkClause), + + XmlSerialize(Box), + + WithClause(super::WithClause), + + InferClause(Box), + + OnConflictClause(Box), + + CommonTableExpr(Box), + + RoleSpec(super::RoleSpec), + + TriggerTransition(super::TriggerTransition), + + PartitionElem(Box), + + PartitionSpec(super::PartitionSpec), + + PartitionBoundSpec(super::PartitionBoundSpec), + + PartitionRangeDatum(Box), + + PartitionCmd(super::PartitionCmd), + + VacuumRelation(super::VacuumRelation), + + InlineCodeBlock(super::InlineCodeBlock), + + CallContext(super::CallContext), + + Integer(super::Integer), + + Float(super::Float), + + String(super::String2), + + BitString(super::BitString), + + Null(super::Null), + + List(super::List), + + IntList(super::IntList), + + OidList(super::OidList), + } +} +#[derive(Clone, PartialEq)] +pub struct Integer { + /// machine integer + + pub ival: i32, +} +#[derive(Clone, PartialEq)] +pub struct Float { + /// string + + pub str: String, +} +#[derive(Clone, PartialEq)] +pub struct String2 { + /// string + + pub str: String, +} +#[derive(Clone, PartialEq)] +pub struct BitString { + /// string + + pub str: String, +} +/// intentionally empty +#[derive(Clone, PartialEq)] +pub struct Null {} +#[derive(Clone, PartialEq)] +pub struct List { + + pub items: Vec, +} +#[derive(Clone, PartialEq)] +pub struct OidList { + + pub items: Vec, +} +#[derive(Clone, PartialEq)] +pub struct IntList { + + pub items: Vec, +} +#[derive(Clone, PartialEq)] +pub struct Alias { + + pub aliasname: String, + + pub colnames: Vec, +} +#[derive(Clone, PartialEq)] +pub struct RangeVar { + + pub catalogname: String, + + pub schemaname: String, + + pub relname: String, + + pub inh: bool, + + pub relpersistence: String, + + pub alias: ::core::option::Option, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct TableFunc { + + pub ns_uris: Vec, + + pub ns_names: Vec, + + pub docexpr: ::core::option::Option>, + + pub rowexpr: ::core::option::Option>, + + pub colnames: Vec, + + pub coltypes: Vec, + + pub coltypmods: Vec, + + pub colcollations: Vec, + + pub colexprs: Vec, + + pub coldefexprs: Vec, + + pub notnulls: Vec, + + pub ordinalitycol: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct Expr {} +#[derive(Clone, PartialEq)] +pub struct Var { + + pub xpr: ::core::option::Option>, + + pub varno: u32, + + pub varattno: i32, + + pub vartype: u32, + + pub vartypmod: i32, + + pub varcollid: u32, + + pub varlevelsup: u32, + + pub varnosyn: u32, + + pub varattnosyn: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct Param { + + pub xpr: ::core::option::Option>, + + pub paramkind: i32, + + pub paramid: i32, + + pub paramtype: u32, + + pub paramtypmod: i32, + + pub paramcollid: u32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct Aggref { + + pub xpr: ::core::option::Option>, + + pub aggfnoid: u32, + + pub aggtype: u32, + + pub aggcollid: u32, + + pub inputcollid: u32, + + pub aggtranstype: u32, + + pub aggargtypes: Vec, + + pub aggdirectargs: Vec, + + pub args: Vec, + + pub aggorder: Vec, + + pub aggdistinct: Vec, + + pub aggfilter: ::core::option::Option>, + + pub aggstar: bool, + + pub aggvariadic: bool, + + pub aggkind: String, + + pub agglevelsup: u32, + + pub aggsplit: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct GroupingFunc { + + pub xpr: ::core::option::Option>, + + pub args: Vec, + + pub refs: Vec, + + pub cols: Vec, + + pub agglevelsup: u32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct WindowFunc { + + pub xpr: ::core::option::Option>, + + pub winfnoid: u32, + + pub wintype: u32, + + pub wincollid: u32, + + pub inputcollid: u32, + + pub args: Vec, + + pub aggfilter: ::core::option::Option>, + + pub winref: u32, + + pub winstar: bool, + + pub winagg: bool, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SubscriptingRef { + + pub xpr: ::core::option::Option>, + + pub refcontainertype: u32, + + pub refelemtype: u32, + + pub reftypmod: i32, + + pub refcollid: u32, + + pub refupperindexpr: Vec, + + pub reflowerindexpr: Vec, + + pub refexpr: ::core::option::Option>, + + pub refassgnexpr: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct FuncExpr { + + pub xpr: ::core::option::Option>, + + pub funcid: u32, + + pub funcresulttype: u32, + + pub funcretset: bool, + + pub funcvariadic: bool, + + pub funcformat: i32, + + pub funccollid: u32, + + pub inputcollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct NamedArgExpr { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub name: String, + + pub argnumber: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct OpExpr { + + pub xpr: ::core::option::Option>, + + pub opno: u32, + + pub opfuncid: u32, + + pub opresulttype: u32, + + pub opretset: bool, + + pub opcollid: u32, + + pub inputcollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct DistinctExpr { + + pub xpr: ::core::option::Option>, + + pub opno: u32, + + pub opfuncid: u32, + + pub opresulttype: u32, + + pub opretset: bool, + + pub opcollid: u32, + + pub inputcollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct NullIfExpr { + + pub xpr: ::core::option::Option>, + + pub opno: u32, + + pub opfuncid: u32, + + pub opresulttype: u32, + + pub opretset: bool, + + pub opcollid: u32, + + pub inputcollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ScalarArrayOpExpr { + + pub xpr: ::core::option::Option>, + + pub opno: u32, + + pub opfuncid: u32, + + pub use_or: bool, + + pub inputcollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct BoolExpr { + + pub xpr: ::core::option::Option>, + + pub boolop: i32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SubLink { + + pub xpr: ::core::option::Option>, + + pub sub_link_type: i32, + + pub sub_link_id: i32, + + pub testexpr: ::core::option::Option>, + + pub oper_name: Vec, + + pub subselect: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SubPlan { + + pub xpr: ::core::option::Option>, + + pub sub_link_type: i32, + + pub testexpr: ::core::option::Option>, + + pub param_ids: Vec, + + pub plan_id: i32, + + pub plan_name: String, + + pub first_col_type: u32, + + pub first_col_typmod: i32, + + pub first_col_collation: u32, + + pub use_hash_table: bool, + + pub unknown_eq_false: bool, + + pub parallel_safe: bool, + + pub set_param: Vec, + + pub par_param: Vec, + + pub args: Vec, + + pub startup_cost: f64, + + pub per_call_cost: f64, +} +#[derive(Clone, PartialEq)] +pub struct AlternativeSubPlan { + + pub xpr: ::core::option::Option>, + + pub subplans: Vec, +} +#[derive(Clone, PartialEq)] +pub struct FieldSelect { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub fieldnum: i32, + + pub resulttype: u32, + + pub resulttypmod: i32, + + pub resultcollid: u32, +} +#[derive(Clone, PartialEq)] +pub struct FieldStore { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub newvals: Vec, + + pub fieldnums: Vec, + + pub resulttype: u32, +} +#[derive(Clone, PartialEq)] +pub struct RelabelType { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub resulttype: u32, + + pub resulttypmod: i32, + + pub resultcollid: u32, + + pub relabelformat: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CoerceViaIo { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub resulttype: u32, + + pub resultcollid: u32, + + pub coerceformat: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ArrayCoerceExpr { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub elemexpr: ::core::option::Option>, + + pub resulttype: u32, + + pub resulttypmod: i32, + + pub resultcollid: u32, + + pub coerceformat: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ConvertRowtypeExpr { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub resulttype: u32, + + pub convertformat: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CollateExpr { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub coll_oid: u32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CaseExpr { + + pub xpr: ::core::option::Option>, + + pub casetype: u32, + + pub casecollid: u32, + + pub arg: ::core::option::Option>, + + pub args: Vec, + + pub defresult: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CaseWhen { + + pub xpr: ::core::option::Option>, + + pub expr: ::core::option::Option>, + + pub result: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CaseTestExpr { + + pub xpr: ::core::option::Option>, + + pub type_id: u32, + + pub type_mod: i32, + + pub collation: u32, +} +#[derive(Clone, PartialEq)] +pub struct ArrayExpr { + + pub xpr: ::core::option::Option>, + + pub array_typeid: u32, + + pub array_collid: u32, + + pub element_typeid: u32, + + pub elements: Vec, + + pub multidims: bool, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RowExpr { + + pub xpr: ::core::option::Option>, + + pub args: Vec, + + pub row_typeid: u32, + + pub row_format: i32, + + pub colnames: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RowCompareExpr { + + pub xpr: ::core::option::Option>, + + pub rctype: i32, + + pub opnos: Vec, + + pub opfamilies: Vec, + + pub inputcollids: Vec, + + pub largs: Vec, + + pub rargs: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CoalesceExpr { + + pub xpr: ::core::option::Option>, + + pub coalescetype: u32, + + pub coalescecollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct MinMaxExpr { + + pub xpr: ::core::option::Option>, + + pub minmaxtype: u32, + + pub minmaxcollid: u32, + + pub inputcollid: u32, + + pub op: i32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SqlValueFunction { + + pub xpr: ::core::option::Option>, + + pub op: i32, + + pub r#type: u32, + + pub typmod: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct XmlExpr { + + pub xpr: ::core::option::Option>, + + pub op: i32, + + pub name: String, + + pub named_args: Vec, + + pub arg_names: Vec, + + pub args: Vec, + + pub xmloption: i32, + + pub r#type: u32, + + pub typmod: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct NullTest { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub nulltesttype: i32, + + pub argisrow: bool, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct BooleanTest { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub booltesttype: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CoerceToDomain { + + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub resulttype: u32, + + pub resulttypmod: i32, + + pub resultcollid: u32, + + pub coercionformat: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CoerceToDomainValue { + + pub xpr: ::core::option::Option>, + + pub type_id: u32, + + pub type_mod: i32, + + pub collation: u32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SetToDefault { + + pub xpr: ::core::option::Option>, + + pub type_id: u32, + + pub type_mod: i32, + + pub collation: u32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CurrentOfExpr { + + pub xpr: ::core::option::Option>, + + pub cvarno: u32, + + pub cursor_name: String, + + pub cursor_param: i32, +} +#[derive(Clone, PartialEq)] +pub struct NextValueExpr { + + pub xpr: ::core::option::Option>, + + pub seqid: u32, + + pub type_id: u32, +} +#[derive(Clone, PartialEq)] +pub struct InferenceElem { + + pub xpr: ::core::option::Option>, + + pub expr: ::core::option::Option>, + + pub infercollid: u32, + + pub inferopclass: u32, +} +#[derive(Clone, PartialEq)] +pub struct TargetEntry { + + pub xpr: ::core::option::Option>, + + pub expr: ::core::option::Option>, + + pub resno: i32, + + pub resname: String, + + pub ressortgroupref: u32, + + pub resorigtbl: u32, + + pub resorigcol: i32, + + pub resjunk: bool, +} +#[derive(Clone, PartialEq)] +pub struct RangeTblRef { + + pub rtindex: i32, +} +#[derive(Clone, PartialEq)] +pub struct JoinExpr { + + pub jointype: i32, + + pub is_natural: bool, + + pub larg: ::core::option::Option>, + + pub rarg: ::core::option::Option>, + + pub using_clause: Vec, + + pub quals: ::core::option::Option>, + + pub alias: ::core::option::Option, + + pub rtindex: i32, +} +#[derive(Clone, PartialEq)] +pub struct FromExpr { + + pub fromlist: Vec, + + pub quals: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct OnConflictExpr { + + pub action: i32, + + pub arbiter_elems: Vec, + + pub arbiter_where: ::core::option::Option>, + + pub constraint: u32, + + pub on_conflict_set: Vec, + + pub on_conflict_where: ::core::option::Option>, + + pub excl_rel_index: i32, + + pub excl_rel_tlist: Vec, +} +#[derive(Clone, PartialEq)] +pub struct IntoClause { + + pub rel: ::core::option::Option, + + pub col_names: Vec, + + pub access_method: String, + + pub options: Vec, + + pub on_commit: i32, + + pub table_space_name: String, + + pub view_query: ::core::option::Option>, + + pub skip_data: bool, +} +#[derive(Clone, PartialEq)] +pub struct RawStmt { + + pub stmt: ::core::option::Option>, + + pub stmt_location: i32, + + pub stmt_len: i32, +} +#[derive(Clone, PartialEq)] +pub struct Query { + + pub command_type: i32, + + pub query_source: i32, + + pub can_set_tag: bool, + + pub utility_stmt: ::core::option::Option>, + + pub result_relation: i32, + + pub has_aggs: bool, + + pub has_window_funcs: bool, + + pub has_target_srfs: bool, + + pub has_sub_links: bool, + + pub has_distinct_on: bool, + + pub has_recursive: bool, + + pub has_modifying_cte: bool, + + pub has_for_update: bool, + + pub has_row_security: bool, + + pub cte_list: Vec, + + pub rtable: Vec, + + pub jointree: ::core::option::Option>, + + pub target_list: Vec, + + pub r#override: i32, + + pub on_conflict: ::core::option::Option>, + + pub returning_list: Vec, + + pub group_clause: Vec, + + pub grouping_sets: Vec, + + pub having_qual: ::core::option::Option>, + + pub window_clause: Vec, + + pub distinct_clause: Vec, + + pub sort_clause: Vec, + + pub limit_offset: ::core::option::Option>, + + pub limit_count: ::core::option::Option>, + + pub limit_option: i32, + + pub row_marks: Vec, + + pub set_operations: ::core::option::Option>, + + pub constraint_deps: Vec, + + pub with_check_options: Vec, + + pub stmt_location: i32, + + pub stmt_len: i32, +} +#[derive(Clone, PartialEq)] +pub struct InsertStmt { + + pub relation: ::core::option::Option, + + pub cols: Vec, + + pub select_stmt: ::core::option::Option>, + + pub on_conflict_clause: ::core::option::Option>, + + pub returning_list: Vec, + + pub with_clause: ::core::option::Option, + + pub r#override: i32, +} +#[derive(Clone, PartialEq)] +pub struct DeleteStmt { + + pub relation: ::core::option::Option, + + pub using_clause: Vec, + + pub where_clause: ::core::option::Option>, + + pub returning_list: Vec, + + pub with_clause: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct UpdateStmt { + + pub relation: ::core::option::Option, + + pub target_list: Vec, + + pub where_clause: ::core::option::Option>, + + pub from_clause: Vec, + + pub returning_list: Vec, + + pub with_clause: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct SelectStmt { + + pub distinct_clause: Vec, + + pub into_clause: ::core::option::Option>, + + pub target_list: Vec, + + pub from_clause: Vec, + + pub where_clause: ::core::option::Option>, + + pub group_clause: Vec, + + pub having_clause: ::core::option::Option>, + + pub window_clause: Vec, + + pub values_lists: Vec, + + pub sort_clause: Vec, + + pub limit_offset: ::core::option::Option>, + + pub limit_count: ::core::option::Option>, + + pub limit_option: i32, + + pub locking_clause: Vec, + + pub with_clause: ::core::option::Option, + + pub op: i32, + + pub all: bool, + + pub larg: ::core::option::Option>, + + pub rarg: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct AlterTableStmt { + + pub relation: ::core::option::Option, + + pub cmds: Vec, + + pub relkind: i32, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterTableCmd { + + pub subtype: i32, + + pub name: String, + + pub num: i32, + + pub newowner: ::core::option::Option, + + pub def: ::core::option::Option>, + + pub behavior: i32, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterDomainStmt { + + pub subtype: String, + + pub type_name: Vec, + + pub name: String, + + pub def: ::core::option::Option>, + + pub behavior: i32, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct SetOperationStmt { + + pub op: i32, + + pub all: bool, + + pub larg: ::core::option::Option>, + + pub rarg: ::core::option::Option>, + + pub col_types: Vec, + + pub col_typmods: Vec, + + pub col_collations: Vec, + + pub group_clauses: Vec, +} +#[derive(Clone, PartialEq)] +pub struct GrantStmt { + + pub is_grant: bool, + + pub targtype: i32, + + pub objtype: i32, + + pub objects: Vec, + + pub privileges: Vec, + + pub grantees: Vec, + + pub grant_option: bool, + + pub behavior: i32, +} +#[derive(Clone, PartialEq)] +pub struct GrantRoleStmt { + + pub granted_roles: Vec, + + pub grantee_roles: Vec, + + pub is_grant: bool, + + pub admin_opt: bool, + + pub grantor: ::core::option::Option, + + pub behavior: i32, +} +#[derive(Clone, PartialEq)] +pub struct AlterDefaultPrivilegesStmt { + + pub options: Vec, + + pub action: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct ClosePortalStmt { + + pub portalname: String, +} +#[derive(Clone, PartialEq)] +pub struct ClusterStmt { + + pub relation: ::core::option::Option, + + pub indexname: String, + + pub options: i32, +} +#[derive(Clone, PartialEq)] +pub struct CopyStmt { + + pub relation: ::core::option::Option, + + pub query: ::core::option::Option>, + + pub attlist: Vec, + + pub is_from: bool, + + pub is_program: bool, + + pub filename: String, + + pub options: Vec, + + pub where_clause: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct CreateStmt { + + pub relation: ::core::option::Option, + + pub table_elts: Vec, + + pub inh_relations: Vec, + + pub partbound: ::core::option::Option, + + pub partspec: ::core::option::Option, + + pub of_typename: ::core::option::Option, + + pub constraints: Vec, + + pub options: Vec, + + pub oncommit: i32, + + pub tablespacename: String, + + pub access_method: String, + + pub if_not_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct DefineStmt { + + pub kind: i32, + + pub oldstyle: bool, + + pub defnames: Vec, + + pub args: Vec, + + pub definition: Vec, + + pub if_not_exists: bool, + + pub replace: bool, +} +#[derive(Clone, PartialEq)] +pub struct DropStmt { + + pub objects: Vec, + + pub remove_type: i32, + + pub behavior: i32, + + pub missing_ok: bool, + + pub concurrent: bool, +} +#[derive(Clone, PartialEq)] +pub struct TruncateStmt { + + pub relations: Vec, + + pub restart_seqs: bool, + + pub behavior: i32, +} +#[derive(Clone, PartialEq)] +pub struct CommentStmt { + + pub objtype: i32, + + pub object: ::core::option::Option>, + + pub comment: String, +} +#[derive(Clone, PartialEq)] +pub struct FetchStmt { + + pub direction: i32, + + pub how_many: i64, + + pub portalname: String, + + pub ismove: bool, +} +#[derive(Clone, PartialEq)] +pub struct IndexStmt { + + pub idxname: String, + + pub relation: ::core::option::Option, + + pub access_method: String, + + pub table_space: String, + + pub index_params: Vec, + + pub index_including_params: Vec, + + pub options: Vec, + + pub where_clause: ::core::option::Option>, + + pub exclude_op_names: Vec, + + pub idxcomment: String, + + pub index_oid: u32, + + pub old_node: u32, + + pub old_create_subid: u32, + + pub old_first_relfilenode_subid: u32, + + pub unique: bool, + + pub primary: bool, + + pub isconstraint: bool, + + pub deferrable: bool, + + pub initdeferred: bool, + + pub transformed: bool, + + pub concurrent: bool, + + pub if_not_exists: bool, + + pub reset_default_tblspc: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateFunctionStmt { + + pub is_procedure: bool, + + pub replace: bool, + + pub funcname: Vec, + + pub parameters: Vec, + + pub return_type: ::core::option::Option, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterFunctionStmt { + + pub objtype: i32, + + pub func: ::core::option::Option, + + pub actions: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DoStmt { + + pub args: Vec, +} +#[derive(Clone, PartialEq)] +pub struct RenameStmt { + + pub rename_type: i32, + + pub relation_type: i32, + + pub relation: ::core::option::Option, + + pub object: ::core::option::Option>, + + pub subname: String, + + pub newname: String, + + pub behavior: i32, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct RuleStmt { + + pub relation: ::core::option::Option, + + pub rulename: String, + + pub where_clause: ::core::option::Option>, + + pub event: i32, + + pub instead: bool, + + pub actions: Vec, + + pub replace: bool, +} +#[derive(Clone, PartialEq)] +pub struct NotifyStmt { + + pub conditionname: String, + + pub payload: String, +} +#[derive(Clone, PartialEq)] +pub struct ListenStmt { + + pub conditionname: String, +} +#[derive(Clone, PartialEq)] +pub struct UnlistenStmt { + + pub conditionname: String, +} +#[derive(Clone, PartialEq)] +pub struct TransactionStmt { + + pub kind: i32, + + pub options: Vec, + + pub savepoint_name: String, + + pub gid: String, + + pub chain: bool, +} +#[derive(Clone, PartialEq)] +pub struct ViewStmt { + + pub view: ::core::option::Option, + + pub aliases: Vec, + + pub query: ::core::option::Option>, + + pub replace: bool, + + pub options: Vec, + + pub with_check_option: i32, +} +#[derive(Clone, PartialEq)] +pub struct LoadStmt { + + pub filename: String, +} +#[derive(Clone, PartialEq)] +pub struct CreateDomainStmt { + + pub domainname: Vec, + + pub type_name: ::core::option::Option, + + pub coll_clause: ::core::option::Option>, + + pub constraints: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreatedbStmt { + + pub dbname: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DropdbStmt { + + pub dbname: String, + + pub missing_ok: bool, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct VacuumStmt { + + pub options: Vec, + + pub rels: Vec, + + pub is_vacuumcmd: bool, +} +#[derive(Clone, PartialEq)] +pub struct ExplainStmt { + + pub query: ::core::option::Option>, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateTableAsStmt { + + pub query: ::core::option::Option>, + + pub into: ::core::option::Option>, + + pub relkind: i32, + + pub is_select_into: bool, + + pub if_not_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateSeqStmt { + + pub sequence: ::core::option::Option, + + pub options: Vec, + + pub owner_id: u32, + + pub for_identity: bool, + + pub if_not_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterSeqStmt { + + pub sequence: ::core::option::Option, + + pub options: Vec, + + pub for_identity: bool, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct VariableSetStmt { + + pub kind: i32, + + pub name: String, + + pub args: Vec, + + pub is_local: bool, +} +#[derive(Clone, PartialEq)] +pub struct VariableShowStmt { + + pub name: String, +} +#[derive(Clone, PartialEq)] +pub struct DiscardStmt { + + pub target: i32, +} +#[derive(Clone, PartialEq)] +pub struct CreateTrigStmt { + + pub trigname: String, + + pub relation: ::core::option::Option, + + pub funcname: Vec, + + pub args: Vec, + + pub row: bool, + + pub timing: i32, + + pub events: i32, + + pub columns: Vec, + + pub when_clause: ::core::option::Option>, + + pub isconstraint: bool, + + pub transition_rels: Vec, + + pub deferrable: bool, + + pub initdeferred: bool, + + pub constrrel: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct CreatePLangStmt { + + pub replace: bool, + + pub plname: String, + + pub plhandler: Vec, + + pub plinline: Vec, + + pub plvalidator: Vec, + + pub pltrusted: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateRoleStmt { + + pub stmt_type: i32, + + pub role: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterRoleStmt { + + pub role: ::core::option::Option, + + pub options: Vec, + + pub action: i32, +} +#[derive(Clone, PartialEq)] +pub struct DropRoleStmt { + + pub roles: Vec, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct LockStmt { + + pub relations: Vec, + + pub mode: i32, + + pub nowait: bool, +} +#[derive(Clone, PartialEq)] +pub struct ConstraintsSetStmt { + + pub constraints: Vec, + + pub deferred: bool, +} +#[derive(Clone, PartialEq)] +pub struct ReindexStmt { + + pub kind: i32, + + pub relation: ::core::option::Option, + + pub name: String, + + pub options: i32, + + pub concurrent: bool, +} +#[derive(Clone, PartialEq)] +pub struct CheckPointStmt {} +#[derive(Clone, PartialEq)] +pub struct CreateSchemaStmt { + + pub schemaname: String, + + pub authrole: ::core::option::Option, + + pub schema_elts: Vec, + + pub if_not_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterDatabaseStmt { + + pub dbname: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterDatabaseSetStmt { + + pub dbname: String, + + pub setstmt: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct AlterRoleSetStmt { + + pub role: ::core::option::Option, + + pub database: String, + + pub setstmt: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct CreateConversionStmt { + + pub conversion_name: Vec, + + pub for_encoding_name: String, + + pub to_encoding_name: String, + + pub func_name: Vec, + + pub def: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateCastStmt { + + pub sourcetype: ::core::option::Option, + + pub targettype: ::core::option::Option, + + pub func: ::core::option::Option, + + pub context: i32, + + pub inout: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateOpClassStmt { + + pub opclassname: Vec, + + pub opfamilyname: Vec, + + pub amname: String, + + pub datatype: ::core::option::Option, + + pub items: Vec, + + pub is_default: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateOpFamilyStmt { + + pub opfamilyname: Vec, + + pub amname: String, +} +#[derive(Clone, PartialEq)] +pub struct AlterOpFamilyStmt { + + pub opfamilyname: Vec, + + pub amname: String, + + pub is_drop: bool, + + pub items: Vec, +} +#[derive(Clone, PartialEq)] +pub struct PrepareStmt { + + pub name: String, + + pub argtypes: Vec, + + pub query: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct ExecuteStmt { + + pub name: String, + + pub params: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DeallocateStmt { + + pub name: String, +} +#[derive(Clone, PartialEq)] +pub struct DeclareCursorStmt { + + pub portalname: String, + + pub options: i32, + + pub query: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct CreateTableSpaceStmt { + + pub tablespacename: String, + + pub owner: ::core::option::Option, + + pub location: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DropTableSpaceStmt { + + pub tablespacename: String, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterObjectDependsStmt { + + pub object_type: i32, + + pub relation: ::core::option::Option, + + pub object: ::core::option::Option>, + + pub extname: ::core::option::Option>, + + pub remove: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterObjectSchemaStmt { + + pub object_type: i32, + + pub relation: ::core::option::Option, + + pub object: ::core::option::Option>, + + pub newschema: String, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterOwnerStmt { + + pub object_type: i32, + + pub relation: ::core::option::Option, + + pub object: ::core::option::Option>, + + pub newowner: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct AlterOperatorStmt { + + pub opername: ::core::option::Option, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterTypeStmt { + + pub type_name: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DropOwnedStmt { + + pub roles: Vec, + + pub behavior: i32, +} +#[derive(Clone, PartialEq)] +pub struct ReassignOwnedStmt { + + pub roles: Vec, + + pub newrole: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct CompositeTypeStmt { + + pub typevar: ::core::option::Option, + + pub coldeflist: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateEnumStmt { + + pub type_name: Vec, + + pub vals: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateRangeStmt { + + pub type_name: Vec, + + pub params: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterEnumStmt { + + pub type_name: Vec, + + pub old_val: String, + + pub new_val: String, + + pub new_val_neighbor: String, + + pub new_val_is_after: bool, + + pub skip_if_new_val_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterTsDictionaryStmt { + + pub dictname: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterTsConfigurationStmt { + + pub kind: i32, + + pub cfgname: Vec, + + pub tokentype: Vec, + + pub dicts: Vec, + + pub r#override: bool, + + pub replace: bool, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateFdwStmt { + + pub fdwname: String, + + pub func_options: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterFdwStmt { + + pub fdwname: String, + + pub func_options: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateForeignServerStmt { + + pub servername: String, + + pub servertype: String, + + pub version: String, + + pub fdwname: String, + + pub if_not_exists: bool, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterForeignServerStmt { + + pub servername: String, + + pub version: String, + + pub options: Vec, + + pub has_version: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateUserMappingStmt { + + pub user: ::core::option::Option, + + pub servername: String, + + pub if_not_exists: bool, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterUserMappingStmt { + + pub user: ::core::option::Option, + + pub servername: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DropUserMappingStmt { + + pub user: ::core::option::Option, + + pub servername: String, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterTableSpaceOptionsStmt { + + pub tablespacename: String, + + pub options: Vec, + + pub is_reset: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterTableMoveAllStmt { + + pub orig_tablespacename: String, + + pub objtype: i32, + + pub roles: Vec, + + pub new_tablespacename: String, + + pub nowait: bool, +} +#[derive(Clone, PartialEq)] +pub struct SecLabelStmt { + + pub objtype: i32, + + pub object: ::core::option::Option>, + + pub provider: String, + + pub label: String, +} +#[derive(Clone, PartialEq)] +pub struct CreateForeignTableStmt { + + pub base_stmt: ::core::option::Option, + + pub servername: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct ImportForeignSchemaStmt { + + pub server_name: String, + + pub remote_schema: String, + + pub local_schema: String, + + pub list_type: i32, + + pub table_list: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateExtensionStmt { + + pub extname: String, + + pub if_not_exists: bool, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterExtensionStmt { + + pub extname: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterExtensionContentsStmt { + + pub extname: String, + + pub action: i32, + + pub objtype: i32, + + pub object: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct CreateEventTrigStmt { + + pub trigname: String, + + pub eventname: String, + + pub whenclause: Vec, + + pub funcname: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterEventTrigStmt { + + pub trigname: String, + + pub tgenabled: String, +} +#[derive(Clone, PartialEq)] +pub struct RefreshMatViewStmt { + + pub concurrent: bool, + + pub skip_data: bool, + + pub relation: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct ReplicaIdentityStmt { + + pub identity_type: String, + + pub name: String, +} +#[derive(Clone, PartialEq)] +pub struct AlterSystemStmt { + + pub setstmt: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct CreatePolicyStmt { + + pub policy_name: String, + + pub table: ::core::option::Option, + + pub cmd_name: String, + + pub permissive: bool, + + pub roles: Vec, + + pub qual: ::core::option::Option>, + + pub with_check: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct AlterPolicyStmt { + + pub policy_name: String, + + pub table: ::core::option::Option, + + pub roles: Vec, + + pub qual: ::core::option::Option>, + + pub with_check: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct CreateTransformStmt { + + pub replace: bool, + + pub type_name: ::core::option::Option, + + pub lang: String, + + pub fromsql: ::core::option::Option, + + pub tosql: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct CreateAmStmt { + + pub amname: String, + + pub handler_name: Vec, + + pub amtype: String, +} +#[derive(Clone, PartialEq)] +pub struct CreatePublicationStmt { + + pub pubname: String, + + pub options: Vec, + + pub tables: Vec, + + pub for_all_tables: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterPublicationStmt { + + pub pubname: String, + + pub options: Vec, + + pub tables: Vec, + + pub for_all_tables: bool, + + pub table_action: i32, +} +#[derive(Clone, PartialEq)] +pub struct CreateSubscriptionStmt { + + pub subname: String, + + pub conninfo: String, + + pub publication: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterSubscriptionStmt { + + pub kind: i32, + + pub subname: String, + + pub conninfo: String, + + pub publication: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DropSubscriptionStmt { + + pub subname: String, + + pub missing_ok: bool, + + pub behavior: i32, +} +#[derive(Clone, PartialEq)] +pub struct CreateStatsStmt { + + pub defnames: Vec, + + pub stat_types: Vec, + + pub exprs: Vec, + + pub relations: Vec, + + pub stxcomment: String, + + pub if_not_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterCollationStmt { + + pub collname: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CallStmt { + + pub funccall: ::core::option::Option>, + + pub funcexpr: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct AlterStatsStmt { + + pub defnames: Vec, + + pub stxstattarget: i32, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AExpr { + + pub kind: i32, + + pub name: Vec, + + pub lexpr: ::core::option::Option>, + + pub rexpr: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ColumnRef { + + pub fields: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ParamRef { + + pub number: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct AConst { + + pub val: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct FuncCall { + + pub funcname: Vec, + + pub args: Vec, + + pub agg_order: Vec, + + pub agg_filter: ::core::option::Option>, + + pub agg_within_group: bool, + + pub agg_star: bool, + + pub agg_distinct: bool, + + pub func_variadic: bool, + + pub over: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct AStar {} +#[derive(Clone, PartialEq)] +pub struct AIndices { + + pub is_slice: bool, + + pub lidx: ::core::option::Option>, + + pub uidx: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct AIndirection { + + pub arg: ::core::option::Option>, + + pub indirection: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AArrayExpr { + + pub elements: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ResTarget { + + pub name: String, + + pub indirection: Vec, + + pub val: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct MultiAssignRef { + + pub source: ::core::option::Option>, + + pub colno: i32, + + pub ncolumns: i32, +} +#[derive(Clone, PartialEq)] +pub struct TypeCast { + + pub arg: ::core::option::Option>, + + pub type_name: ::core::option::Option, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CollateClause { + + pub arg: ::core::option::Option>, + + pub collname: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SortBy { + + pub node: ::core::option::Option>, + + pub sortby_dir: i32, + + pub sortby_nulls: i32, + + pub use_op: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct WindowDef { + + pub name: String, + + pub refname: String, + + pub partition_clause: Vec, + + pub order_clause: Vec, + + pub frame_options: i32, + + pub start_offset: ::core::option::Option>, + + pub end_offset: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RangeSubselect { + + pub lateral: bool, + + pub subquery: ::core::option::Option>, + + pub alias: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct RangeFunction { + + pub lateral: bool, + + pub ordinality: bool, + + pub is_rowsfrom: bool, + + pub functions: Vec, + + pub alias: ::core::option::Option, + + pub coldeflist: Vec, +} +#[derive(Clone, PartialEq)] +pub struct RangeTableSample { + + pub relation: ::core::option::Option>, + + pub method: Vec, + + pub args: Vec, + + pub repeatable: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RangeTableFunc { + + pub lateral: bool, + + pub docexpr: ::core::option::Option>, + + pub rowexpr: ::core::option::Option>, + + pub namespaces: Vec, + + pub columns: Vec, + + pub alias: ::core::option::Option, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RangeTableFuncCol { + + pub colname: String, + + pub type_name: ::core::option::Option, + + pub for_ordinality: bool, + + pub is_not_null: bool, + + pub colexpr: ::core::option::Option>, + + pub coldefexpr: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct TypeName { + + pub names: Vec, + + pub type_oid: u32, + + pub setof: bool, + + pub pct_type: bool, + + pub typmods: Vec, + + pub typemod: i32, + + pub array_bounds: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ColumnDef { + + pub colname: String, + + pub type_name: ::core::option::Option, + + pub inhcount: i32, + + pub is_local: bool, + + pub is_not_null: bool, + + pub is_from_type: bool, + + pub storage: String, + + pub raw_default: ::core::option::Option>, + + pub cooked_default: ::core::option::Option>, + + pub identity: String, + + pub identity_sequence: ::core::option::Option, + + pub generated: String, + + pub coll_clause: ::core::option::Option>, + + pub coll_oid: u32, + + pub constraints: Vec, + + pub fdwoptions: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct IndexElem { + + pub name: String, + + pub expr: ::core::option::Option>, + + pub indexcolname: String, + + pub collation: Vec, + + pub opclass: Vec, + + pub opclassopts: Vec, + + pub ordering: i32, + + pub nulls_ordering: i32, +} +#[derive(Clone, PartialEq)] +pub struct Constraint { + + pub contype: i32, + + pub conname: String, + + pub deferrable: bool, + + pub initdeferred: bool, + + pub location: i32, + + pub is_no_inherit: bool, + + pub raw_expr: ::core::option::Option>, + + pub cooked_expr: String, + + pub generated_when: String, + + pub keys: Vec, + + pub including: Vec, + + pub exclusions: Vec, + + pub options: Vec, + + pub indexname: String, + + pub indexspace: String, + + pub reset_default_tblspc: bool, + + pub access_method: String, + + pub where_clause: ::core::option::Option>, + + pub pktable: ::core::option::Option, + + pub fk_attrs: Vec, + + pub pk_attrs: Vec, + + pub fk_matchtype: String, + + pub fk_upd_action: String, + + pub fk_del_action: String, + + pub old_conpfeqop: Vec, + + pub old_pktable_oid: u32, + + pub skip_validation: bool, + + pub initially_valid: bool, +} +#[derive(Clone, PartialEq)] +pub struct DefElem { + + pub defnamespace: String, + + pub defname: String, + + pub arg: ::core::option::Option>, + + pub defaction: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RangeTblEntry { + + pub rtekind: i32, + + pub relid: u32, + + pub relkind: String, + + pub rellockmode: i32, + + pub tablesample: ::core::option::Option>, + + pub subquery: ::core::option::Option>, + + pub security_barrier: bool, + + pub jointype: i32, + + pub joinmergedcols: i32, + + pub joinaliasvars: Vec, + + pub joinleftcols: Vec, + + pub joinrightcols: Vec, + + pub functions: Vec, + + pub funcordinality: bool, + + pub tablefunc: ::core::option::Option>, + + pub values_lists: Vec, + + pub ctename: String, + + pub ctelevelsup: u32, + + pub self_reference: bool, + + pub coltypes: Vec, + + pub coltypmods: Vec, + + pub colcollations: Vec, + + pub enrname: String, + + pub enrtuples: f64, + + pub alias: ::core::option::Option, + + pub eref: ::core::option::Option, + + pub lateral: bool, + + pub inh: bool, + + pub in_from_cl: bool, + + pub required_perms: u32, + + pub check_as_user: u32, + + pub selected_cols: Vec, + + pub inserted_cols: Vec, + + pub updated_cols: Vec, + + pub extra_updated_cols: Vec, + + pub security_quals: Vec, +} +#[derive(Clone, PartialEq)] +pub struct RangeTblFunction { + + pub funcexpr: ::core::option::Option>, + + pub funccolcount: i32, + + pub funccolnames: Vec, + + pub funccoltypes: Vec, + + pub funccoltypmods: Vec, + + pub funccolcollations: Vec, + + pub funcparams: Vec, +} +#[derive(Clone, PartialEq)] +pub struct TableSampleClause { + + pub tsmhandler: u32, + + pub args: Vec, + + pub repeatable: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct WithCheckOption { + + pub kind: i32, + + pub relname: String, + + pub polname: String, + + pub qual: ::core::option::Option>, + + pub cascaded: bool, +} +#[derive(Clone, PartialEq)] +pub struct SortGroupClause { + + pub tle_sort_group_ref: u32, + + pub eqop: u32, + + pub sortop: u32, + + pub nulls_first: bool, + + pub hashable: bool, +} +#[derive(Clone, PartialEq)] +pub struct GroupingSet { + + pub kind: i32, + + pub content: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct WindowClause { + + pub name: String, + + pub refname: String, + + pub partition_clause: Vec, + + pub order_clause: Vec, + + pub frame_options: i32, + + pub start_offset: ::core::option::Option>, + + pub end_offset: ::core::option::Option>, + + pub start_in_range_func: u32, + + pub end_in_range_func: u32, + + pub in_range_coll: u32, + + pub in_range_asc: bool, + + pub in_range_nulls_first: bool, + + pub winref: u32, + + pub copied_order: bool, +} +#[derive(Clone, PartialEq)] +pub struct ObjectWithArgs { + + pub objname: Vec, + + pub objargs: Vec, + + pub args_unspecified: bool, +} +#[derive(Clone, PartialEq)] +pub struct AccessPriv { + + pub priv_name: String, + + pub cols: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateOpClassItem { + + pub itemtype: i32, + + pub name: ::core::option::Option, + + pub number: i32, + + pub order_family: Vec, + + pub class_args: Vec, + + pub storedtype: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct TableLikeClause { + + pub relation: ::core::option::Option, + + pub options: u32, + + pub relation_oid: u32, +} +#[derive(Clone, PartialEq)] +pub struct FunctionParameter { + + pub name: String, + + pub arg_type: ::core::option::Option, + + pub mode: i32, + + pub defexpr: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct LockingClause { + + pub locked_rels: Vec, + + pub strength: i32, + + pub wait_policy: i32, +} +#[derive(Clone, PartialEq)] +pub struct RowMarkClause { + + pub rti: u32, + + pub strength: i32, + + pub wait_policy: i32, + + pub pushed_down: bool, +} +#[derive(Clone, PartialEq)] +pub struct XmlSerialize { + + pub xmloption: i32, + + pub expr: ::core::option::Option>, + + pub type_name: ::core::option::Option, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct WithClause { + + pub ctes: Vec, + + pub recursive: bool, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct InferClause { + + pub index_elems: Vec, + + pub where_clause: ::core::option::Option>, + + pub conname: String, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct OnConflictClause { + + pub action: i32, + + pub infer: ::core::option::Option>, + + pub target_list: Vec, + + pub where_clause: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CommonTableExpr { + + pub ctename: String, + + pub aliascolnames: Vec, + + pub ctematerialized: i32, + + pub ctequery: ::core::option::Option>, + + pub location: i32, + + pub cterecursive: bool, + + pub cterefcount: i32, + + pub ctecolnames: Vec, + + pub ctecoltypes: Vec, + + pub ctecoltypmods: Vec, + + pub ctecolcollations: Vec, +} +#[derive(Clone, PartialEq)] +pub struct RoleSpec { + + pub roletype: i32, + + pub rolename: String, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct TriggerTransition { + + pub name: String, + + pub is_new: bool, + + pub is_table: bool, +} +#[derive(Clone, PartialEq)] +pub struct PartitionElem { + + pub name: String, + + pub expr: ::core::option::Option>, + + pub collation: Vec, + + pub opclass: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct PartitionSpec { + + pub strategy: String, + + pub part_params: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct PartitionBoundSpec { + + pub strategy: String, + + pub is_default: bool, + + pub modulus: i32, + + pub remainder: i32, + + pub listdatums: Vec, + + pub lowerdatums: Vec, + + pub upperdatums: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct PartitionRangeDatum { + + pub kind: i32, + + pub value: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct PartitionCmd { + + pub name: ::core::option::Option, + + pub bound: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct VacuumRelation { + + pub relation: ::core::option::Option, + + pub oid: u32, + + pub va_cols: Vec, +} +#[derive(Clone, PartialEq)] +pub struct InlineCodeBlock { + + pub source_text: String, + + pub lang_oid: u32, + + pub lang_is_trusted: bool, + + pub atomic: bool, +} +#[derive(Clone, PartialEq)] +pub struct CallContext { + + pub atomic: bool, +} +#[derive(Clone, PartialEq)] +pub struct ScanToken { + + pub start: i32, + + pub end: i32, + + pub token: i32, + + pub keyword_kind: i32, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum OverridingKind { + Undefined = 0, + OverridingNotSet = 1, + OverridingUserValue = 2, + OverridingSystemValue = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum QuerySource { + Undefined = 0, + QsrcOriginal = 1, + QsrcParser = 2, + QsrcInsteadRule = 3, + QsrcQualInsteadRule = 4, + QsrcNonInsteadRule = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SortByDir { + Undefined = 0, + SortbyDefault = 1, + SortbyAsc = 2, + SortbyDesc = 3, + SortbyUsing = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SortByNulls { + Undefined = 0, + SortbyNullsDefault = 1, + SortbyNullsFirst = 2, + SortbyNullsLast = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AExprKind { + Undefined = 0, + AexprOp = 1, + AexprOpAny = 2, + AexprOpAll = 3, + AexprDistinct = 4, + AexprNotDistinct = 5, + AexprNullif = 6, + AexprOf = 7, + AexprIn = 8, + AexprLike = 9, + AexprIlike = 10, + AexprSimilar = 11, + AexprBetween = 12, + AexprNotBetween = 13, + AexprBetweenSym = 14, + AexprNotBetweenSym = 15, + AexprParen = 16, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum RoleSpecType { + Undefined = 0, + RolespecCstring = 1, + RolespecCurrentUser = 2, + RolespecSessionUser = 3, + RolespecPublic = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum TableLikeOption { + Undefined = 0, + CreateTableLikeComments = 1, + CreateTableLikeConstraints = 2, + CreateTableLikeDefaults = 3, + CreateTableLikeGenerated = 4, + CreateTableLikeIdentity = 5, + CreateTableLikeIndexes = 6, + CreateTableLikeStatistics = 7, + CreateTableLikeStorage = 8, + CreateTableLikeAll = 9, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum DefElemAction { + Undefined = 0, + DefelemUnspec = 1, + DefelemSet = 2, + DefelemAdd = 3, + DefelemDrop = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum PartitionRangeDatumKind { + Undefined = 0, + PartitionRangeDatumMinvalue = 1, + PartitionRangeDatumValue = 2, + PartitionRangeDatumMaxvalue = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum RteKind { + RtekindUndefined = 0, + RteRelation = 1, + RteSubquery = 2, + RteJoin = 3, + RteFunction = 4, + RteTablefunc = 5, + RteValues = 6, + RteCte = 7, + RteNamedtuplestore = 8, + RteResult = 9, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum WcoKind { + WcokindUndefined = 0, + WcoViewCheck = 1, + WcoRlsInsertCheck = 2, + WcoRlsUpdateCheck = 3, + WcoRlsConflictCheck = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum GroupingSetKind { + Undefined = 0, + GroupingSetEmpty = 1, + GroupingSetSimple = 2, + GroupingSetRollup = 3, + GroupingSetCube = 4, + GroupingSetSets = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum CteMaterialize { + CtematerializeUndefined = 0, + Default = 1, + Always = 2, + Never = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SetOperation { + Undefined = 0, + SetopNone = 1, + SetopUnion = 2, + SetopIntersect = 3, + SetopExcept = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ObjectType { + Undefined = 0, + ObjectAccessMethod = 1, + ObjectAggregate = 2, + ObjectAmop = 3, + ObjectAmproc = 4, + ObjectAttribute = 5, + ObjectCast = 6, + ObjectColumn = 7, + ObjectCollation = 8, + ObjectConversion = 9, + ObjectDatabase = 10, + ObjectDefault = 11, + ObjectDefacl = 12, + ObjectDomain = 13, + ObjectDomconstraint = 14, + ObjectEventTrigger = 15, + ObjectExtension = 16, + ObjectFdw = 17, + ObjectForeignServer = 18, + ObjectForeignTable = 19, + ObjectFunction = 20, + ObjectIndex = 21, + ObjectLanguage = 22, + ObjectLargeobject = 23, + ObjectMatview = 24, + ObjectOpclass = 25, + ObjectOperator = 26, + ObjectOpfamily = 27, + ObjectPolicy = 28, + ObjectProcedure = 29, + ObjectPublication = 30, + ObjectPublicationRel = 31, + ObjectRole = 32, + ObjectRoutine = 33, + ObjectRule = 34, + ObjectSchema = 35, + ObjectSequence = 36, + ObjectSubscription = 37, + ObjectStatisticExt = 38, + ObjectTabconstraint = 39, + ObjectTable = 40, + ObjectTablespace = 41, + ObjectTransform = 42, + ObjectTrigger = 43, + ObjectTsconfiguration = 44, + ObjectTsdictionary = 45, + ObjectTsparser = 46, + ObjectTstemplate = 47, + ObjectType = 48, + ObjectUserMapping = 49, + ObjectView = 50, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum DropBehavior { + Undefined = 0, + DropRestrict = 1, + DropCascade = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AlterTableType { + Undefined = 0, + AtAddColumn = 1, + AtAddColumnRecurse = 2, + AtAddColumnToView = 3, + AtColumnDefault = 4, + AtCookedColumnDefault = 5, + AtDropNotNull = 6, + AtSetNotNull = 7, + AtDropExpression = 8, + AtCheckNotNull = 9, + AtSetStatistics = 10, + AtSetOptions = 11, + AtResetOptions = 12, + AtSetStorage = 13, + AtDropColumn = 14, + AtDropColumnRecurse = 15, + AtAddIndex = 16, + AtReAddIndex = 17, + AtAddConstraint = 18, + AtAddConstraintRecurse = 19, + AtReAddConstraint = 20, + AtReAddDomainConstraint = 21, + AtAlterConstraint = 22, + AtValidateConstraint = 23, + AtValidateConstraintRecurse = 24, + AtAddIndexConstraint = 25, + AtDropConstraint = 26, + AtDropConstraintRecurse = 27, + AtReAddComment = 28, + AtAlterColumnType = 29, + AtAlterColumnGenericOptions = 30, + AtChangeOwner = 31, + AtClusterOn = 32, + AtDropCluster = 33, + AtSetLogged = 34, + AtSetUnLogged = 35, + AtDropOids = 36, + AtSetTableSpace = 37, + AtSetRelOptions = 38, + AtResetRelOptions = 39, + AtReplaceRelOptions = 40, + AtEnableTrig = 41, + AtEnableAlwaysTrig = 42, + AtEnableReplicaTrig = 43, + AtDisableTrig = 44, + AtEnableTrigAll = 45, + AtDisableTrigAll = 46, + AtEnableTrigUser = 47, + AtDisableTrigUser = 48, + AtEnableRule = 49, + AtEnableAlwaysRule = 50, + AtEnableReplicaRule = 51, + AtDisableRule = 52, + AtAddInherit = 53, + AtDropInherit = 54, + AtAddOf = 55, + AtDropOf = 56, + AtReplicaIdentity = 57, + AtEnableRowSecurity = 58, + AtDisableRowSecurity = 59, + AtForceRowSecurity = 60, + AtNoForceRowSecurity = 61, + AtGenericOptions = 62, + AtAttachPartition = 63, + AtDetachPartition = 64, + AtAddIdentity = 65, + AtSetIdentity = 66, + AtDropIdentity = 67, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum GrantTargetType { + Undefined = 0, + AclTargetObject = 1, + AclTargetAllInSchema = 2, + AclTargetDefaults = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum VariableSetKind { + Undefined = 0, + VarSetValue = 1, + VarSetDefault = 2, + VarSetCurrent = 3, + VarSetMulti = 4, + VarReset = 5, + VarResetAll = 6, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ConstrType { + Undefined = 0, + ConstrNull = 1, + ConstrNotnull = 2, + ConstrDefault = 3, + ConstrIdentity = 4, + ConstrGenerated = 5, + ConstrCheck = 6, + ConstrPrimary = 7, + ConstrUnique = 8, + ConstrExclusion = 9, + ConstrForeign = 10, + ConstrAttrDeferrable = 11, + ConstrAttrNotDeferrable = 12, + ConstrAttrDeferred = 13, + ConstrAttrImmediate = 14, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ImportForeignSchemaType { + Undefined = 0, + FdwImportSchemaAll = 1, + FdwImportSchemaLimitTo = 2, + FdwImportSchemaExcept = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum RoleStmtType { + Undefined = 0, + RolestmtRole = 1, + RolestmtUser = 2, + RolestmtGroup = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum FetchDirection { + Undefined = 0, + FetchForward = 1, + FetchBackward = 2, + FetchAbsolute = 3, + FetchRelative = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum FunctionParameterMode { + Undefined = 0, + FuncParamIn = 1, + FuncParamOut = 2, + FuncParamInout = 3, + FuncParamVariadic = 4, + FuncParamTable = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum TransactionStmtKind { + Undefined = 0, + TransStmtBegin = 1, + TransStmtStart = 2, + TransStmtCommit = 3, + TransStmtRollback = 4, + TransStmtSavepoint = 5, + TransStmtRelease = 6, + TransStmtRollbackTo = 7, + TransStmtPrepare = 8, + TransStmtCommitPrepared = 9, + TransStmtRollbackPrepared = 10, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ViewCheckOption { + Undefined = 0, + NoCheckOption = 1, + LocalCheckOption = 2, + CascadedCheckOption = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ClusterOption { + Undefined = 0, + CluoptRecheck = 1, + CluoptVerbose = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum DiscardMode { + Undefined = 0, + DiscardAll = 1, + DiscardPlans = 2, + DiscardSequences = 3, + DiscardTemp = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ReindexObjectType { + Undefined = 0, + ReindexObjectIndex = 1, + ReindexObjectTable = 2, + ReindexObjectSchema = 3, + ReindexObjectSystem = 4, + ReindexObjectDatabase = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AlterTsConfigType { + AlterTsconfigTypeUndefined = 0, + AlterTsconfigAddMapping = 1, + AlterTsconfigAlterMappingForToken = 2, + AlterTsconfigReplaceDict = 3, + AlterTsconfigReplaceDictForToken = 4, + AlterTsconfigDropMapping = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AlterSubscriptionType { + Undefined = 0, + AlterSubscriptionOptions = 1, + AlterSubscriptionConnection = 2, + AlterSubscriptionPublication = 3, + AlterSubscriptionRefresh = 4, + AlterSubscriptionEnabled = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum OnCommitAction { + Undefined = 0, + OncommitNoop = 1, + OncommitPreserveRows = 2, + OncommitDeleteRows = 3, + OncommitDrop = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ParamKind { + Undefined = 0, + ParamExtern = 1, + ParamExec = 2, + ParamSublink = 3, + ParamMultiexpr = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum CoercionContext { + Undefined = 0, + CoercionImplicit = 1, + CoercionAssignment = 2, + CoercionExplicit = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum CoercionForm { + Undefined = 0, + CoerceExplicitCall = 1, + CoerceExplicitCast = 2, + CoerceImplicitCast = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum BoolExprType { + Undefined = 0, + AndExpr = 1, + OrExpr = 2, + NotExpr = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SubLinkType { + Undefined = 0, + ExistsSublink = 1, + AllSublink = 2, + AnySublink = 3, + RowcompareSublink = 4, + ExprSublink = 5, + MultiexprSublink = 6, + ArraySublink = 7, + CteSublink = 8, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum RowCompareType { + Undefined = 0, + RowcompareLt = 1, + RowcompareLe = 2, + RowcompareEq = 3, + RowcompareGe = 4, + RowcompareGt = 5, + RowcompareNe = 6, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum MinMaxOp { + Undefined = 0, + IsGreatest = 1, + IsLeast = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SqlValueFunctionOp { + SqlvalueFunctionOpUndefined = 0, + SvfopCurrentDate = 1, + SvfopCurrentTime = 2, + SvfopCurrentTimeN = 3, + SvfopCurrentTimestamp = 4, + SvfopCurrentTimestampN = 5, + SvfopLocaltime = 6, + SvfopLocaltimeN = 7, + SvfopLocaltimestamp = 8, + SvfopLocaltimestampN = 9, + SvfopCurrentRole = 10, + SvfopCurrentUser = 11, + SvfopUser = 12, + SvfopSessionUser = 13, + SvfopCurrentCatalog = 14, + SvfopCurrentSchema = 15, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum XmlExprOp { + Undefined = 0, + IsXmlconcat = 1, + IsXmlelement = 2, + IsXmlforest = 3, + IsXmlparse = 4, + IsXmlpi = 5, + IsXmlroot = 6, + IsXmlserialize = 7, + IsDocument = 8, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum XmlOptionType { + Undefined = 0, + XmloptionDocument = 1, + XmloptionContent = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum NullTestType { + Undefined = 0, + IsNull = 1, + IsNotNull = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum BoolTestType { + Undefined = 0, + IsTrue = 1, + IsNotTrue = 2, + IsFalse = 3, + IsNotFalse = 4, + IsUnknown = 5, + IsNotUnknown = 6, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum CmdType { + Undefined = 0, + CmdUnknown = 1, + CmdSelect = 2, + CmdUpdate = 3, + CmdInsert = 4, + CmdDelete = 5, + CmdUtility = 6, + CmdNothing = 7, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum JoinType { + Undefined = 0, + JoinInner = 1, + JoinLeft = 2, + JoinFull = 3, + JoinRight = 4, + JoinSemi = 5, + JoinAnti = 6, + JoinUniqueOuter = 7, + JoinUniqueInner = 8, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AggStrategy { + Undefined = 0, + AggPlain = 1, + AggSorted = 2, + AggHashed = 3, + AggMixed = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AggSplit { + Undefined = 0, + AggsplitSimple = 1, + AggsplitInitialSerial = 2, + AggsplitFinalDeserial = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SetOpCmd { + Undefined = 0, + SetopcmdIntersect = 1, + SetopcmdIntersectAll = 2, + SetopcmdExcept = 3, + SetopcmdExceptAll = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SetOpStrategy { + Undefined = 0, + SetopSorted = 1, + SetopHashed = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum OnConflictAction { + Undefined = 0, + OnconflictNone = 1, + OnconflictNothing = 2, + OnconflictUpdate = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum LimitOption { + Undefined = 0, + Default = 1, + Count = 2, + WithTies = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum LockClauseStrength { + Undefined = 0, + LcsNone = 1, + LcsForkeyshare = 2, + LcsForshare = 3, + LcsFornokeyupdate = 4, + LcsForupdate = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum LockWaitPolicy { + Undefined = 0, + LockWaitBlock = 1, + LockWaitSkip = 2, + LockWaitError = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum LockTupleMode { + Undefined = 0, + LockTupleKeyShare = 1, + LockTupleShare = 2, + LockTupleNoKeyExclusive = 3, + LockTupleExclusive = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum KeywordKind { + NoKeyword = 0, + UnreservedKeyword = 1, + ColNameKeyword = 2, + TypeFuncNameKeyword = 3, + ReservedKeyword = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum Token { + Nul = 0, + /// Single-character tokens that are returned 1:1 (identical with "self" list in scan.l) + /// Either supporting syntax, or single-character operators (some can be both) + /// Also see + /// + /// "%" + Ascii37 = 37, + /// "(" + Ascii40 = 40, + /// ")" + Ascii41 = 41, + /// "*" + Ascii42 = 42, + /// "+" + Ascii43 = 43, + /// "," + Ascii44 = 44, + /// "-" + Ascii45 = 45, + /// "." + Ascii46 = 46, + /// "/" + Ascii47 = 47, + /// ":" + Ascii58 = 58, + /// ";" + Ascii59 = 59, + /// "<" + Ascii60 = 60, + /// "=" + Ascii61 = 61, + /// ">" + Ascii62 = 62, + /// "?" + Ascii63 = 63, + /// "[" + Ascii91 = 91, + /// "\" + Ascii92 = 92, + /// "]" + Ascii93 = 93, + /// "^" + Ascii94 = 94, + /// Named tokens in scan.l + Ident = 258, + Uident = 259, + Fconst = 260, + Sconst = 261, + Usconst = 262, + Bconst = 263, + Xconst = 264, + Op = 265, + Iconst = 266, + Param = 267, + Typecast = 268, + DotDot = 269, + ColonEquals = 270, + EqualsGreater = 271, + LessEquals = 272, + GreaterEquals = 273, + NotEquals = 274, + SqlComment = 275, + CComment = 276, + AbortP = 277, + AbsoluteP = 278, + Access = 279, + Action = 280, + AddP = 281, + Admin = 282, + After = 283, + Aggregate = 284, + All = 285, + Also = 286, + Alter = 287, + Always = 288, + Analyse = 289, + Analyze = 290, + And = 291, + Any = 292, + Array = 293, + As = 294, + Asc = 295, + Assertion = 296, + Assignment = 297, + Asymmetric = 298, + At = 299, + Attach = 300, + Attribute = 301, + Authorization = 302, + Backward = 303, + Before = 304, + BeginP = 305, + Between = 306, + Bigint = 307, + Binary = 308, + Bit = 309, + BooleanP = 310, + Both = 311, + By = 312, + Cache = 313, + Call = 314, + Called = 315, + Cascade = 316, + Cascaded = 317, + Case = 318, + Cast = 319, + CatalogP = 320, + Chain = 321, + CharP = 322, + Character = 323, + Characteristics = 324, + Check = 325, + Checkpoint = 326, + Class = 327, + Close = 328, + Cluster = 329, + Coalesce = 330, + Collate = 331, + Collation = 332, + Column = 333, + Columns = 334, + Comment = 335, + Comments = 336, + Commit = 337, + Committed = 338, + Concurrently = 339, + Configuration = 340, + Conflict = 341, + Connection = 342, + Constraint = 343, + Constraints = 344, + ContentP = 345, + ContinueP = 346, + ConversionP = 347, + Copy = 348, + Cost = 349, + Create = 350, + Cross = 351, + Csv = 352, + Cube = 353, + CurrentP = 354, + CurrentCatalog = 355, + CurrentDate = 356, + CurrentRole = 357, + CurrentSchema = 358, + CurrentTime = 359, + CurrentTimestamp = 360, + CurrentUser = 361, + Cursor = 362, + Cycle = 363, + DataP = 364, + Database = 365, + DayP = 366, + Deallocate = 367, + Dec = 368, + DecimalP = 369, + Declare = 370, + Default = 371, + Defaults = 372, + Deferrable = 373, + Deferred = 374, + Definer = 375, + DeleteP = 376, + Delimiter = 377, + Delimiters = 378, + Depends = 379, + Desc = 380, + Detach = 381, + Dictionary = 382, + DisableP = 383, + Discard = 384, + Distinct = 385, + Do = 386, + DocumentP = 387, + DomainP = 388, + DoubleP = 389, + Drop = 390, + Each = 391, + Else = 392, + EnableP = 393, + Encoding = 394, + Encrypted = 395, + EndP = 396, + EnumP = 397, + Escape = 398, + Event = 399, + Except = 400, + Exclude = 401, + Excluding = 402, + Exclusive = 403, + Execute = 404, + Exists = 405, + Explain = 406, + Expression = 407, + Extension = 408, + External = 409, + Extract = 410, + FalseP = 411, + Family = 412, + Fetch = 413, + Filter = 414, + FirstP = 415, + FloatP = 416, + Following = 417, + For = 418, + Force = 419, + Foreign = 420, + Forward = 421, + Freeze = 422, + From = 423, + Full = 424, + Function = 425, + Functions = 426, + Generated = 427, + Global = 428, + Grant = 429, + Granted = 430, + Greatest = 431, + GroupP = 432, + Grouping = 433, + Groups = 434, + Handler = 435, + Having = 436, + HeaderP = 437, + Hold = 438, + HourP = 439, + IdentityP = 440, + IfP = 441, + Ilike = 442, + Immediate = 443, + Immutable = 444, + ImplicitP = 445, + ImportP = 446, + InP = 447, + Include = 448, + Including = 449, + Increment = 450, + Index = 451, + Indexes = 452, + Inherit = 453, + Inherits = 454, + Initially = 455, + InlineP = 456, + InnerP = 457, + Inout = 458, + InputP = 459, + Insensitive = 460, + Insert = 461, + Instead = 462, + IntP = 463, + Integer = 464, + Intersect = 465, + Interval = 466, + Into = 467, + Invoker = 468, + Is = 469, + Isnull = 470, + Isolation = 471, + Join = 472, + Key = 473, + Label = 474, + Language = 475, + LargeP = 476, + LastP = 477, + LateralP = 478, + Leading = 479, + Leakproof = 480, + Least = 481, + Left = 482, + Level = 483, + Like = 484, + Limit = 485, + Listen = 486, + Load = 487, + Local = 488, + Localtime = 489, + Localtimestamp = 490, + Location = 491, + LockP = 492, + Locked = 493, + Logged = 494, + Mapping = 495, + Match = 496, + Materialized = 497, + Maxvalue = 498, + Method = 499, + MinuteP = 500, + Minvalue = 501, + Mode = 502, + MonthP = 503, + Move = 504, + NameP = 505, + Names = 506, + National = 507, + Natural = 508, + Nchar = 509, + New = 510, + Next = 511, + Nfc = 512, + Nfd = 513, + Nfkc = 514, + Nfkd = 515, + No = 516, + None = 517, + Normalize = 518, + Normalized = 519, + Not = 520, + Nothing = 521, + Notify = 522, + Notnull = 523, + Nowait = 524, + NullP = 525, + Nullif = 526, + NullsP = 527, + Numeric = 528, + ObjectP = 529, + Of = 530, + Off = 531, + Offset = 532, + Oids = 533, + Old = 534, + On = 535, + Only = 536, + Operator = 537, + Option = 538, + Options = 539, + Or = 540, + Order = 541, + Ordinality = 542, + Others = 543, + OutP = 544, + OuterP = 545, + Over = 546, + Overlaps = 547, + Overlay = 548, + Overriding = 549, + Owned = 550, + Owner = 551, + Parallel = 552, + Parser = 553, + Partial = 554, + Partition = 555, + Passing = 556, + Password = 557, + Placing = 558, + Plans = 559, + Policy = 560, + Position = 561, + Preceding = 562, + Precision = 563, + Preserve = 564, + Prepare = 565, + Prepared = 566, + Primary = 567, + Prior = 568, + Privileges = 569, + Procedural = 570, + Procedure = 571, + Procedures = 572, + Program = 573, + Publication = 574, + Quote = 575, + Range = 576, + Read = 577, + Real = 578, + Reassign = 579, + Recheck = 580, + Recursive = 581, + Ref = 582, + References = 583, + Referencing = 584, + Refresh = 585, + Reindex = 586, + RelativeP = 587, + Release = 588, + Rename = 589, + Repeatable = 590, + Replace = 591, + Replica = 592, + Reset = 593, + Restart = 594, + Restrict = 595, + Returning = 596, + Returns = 597, + Revoke = 598, + Right = 599, + Role = 600, + Rollback = 601, + Rollup = 602, + Routine = 603, + Routines = 604, + Row = 605, + Rows = 606, + Rule = 607, + Savepoint = 608, + Schema = 609, + Schemas = 610, + Scroll = 611, + Search = 612, + SecondP = 613, + Security = 614, + Select = 615, + Sequence = 616, + Sequences = 617, + Serializable = 618, + Server = 619, + Session = 620, + SessionUser = 621, + Set = 622, + Sets = 623, + Setof = 624, + Share = 625, + Show = 626, + Similar = 627, + Simple = 628, + Skip = 629, + Smallint = 630, + Snapshot = 631, + Some = 632, + SqlP = 633, + Stable = 634, + StandaloneP = 635, + Start = 636, + Statement = 637, + Statistics = 638, + Stdin = 639, + Stdout = 640, + Storage = 641, + Stored = 642, + StrictP = 643, + StripP = 644, + Subscription = 645, + Substring = 646, + Support = 647, + Symmetric = 648, + Sysid = 649, + SystemP = 650, + Table = 651, + Tables = 652, + Tablesample = 653, + Tablespace = 654, + Temp = 655, + Template = 656, + Temporary = 657, + TextP = 658, + Then = 659, + Ties = 660, + Time = 661, + Timestamp = 662, + To = 663, + Trailing = 664, + Transaction = 665, + Transform = 666, + Treat = 667, + Trigger = 668, + Trim = 669, + TrueP = 670, + Truncate = 671, + Trusted = 672, + TypeP = 673, + TypesP = 674, + Uescape = 675, + Unbounded = 676, + Uncommitted = 677, + Unencrypted = 678, + Union = 679, + Unique = 680, + Unknown = 681, + Unlisten = 682, + Unlogged = 683, + Until = 684, + Update = 685, + User = 686, + Using = 687, + Vacuum = 688, + Valid = 689, + Validate = 690, + Validator = 691, + ValueP = 692, + Values = 693, + Varchar = 694, + Variadic = 695, + Varying = 696, + Verbose = 697, + VersionP = 698, + View = 699, + Views = 700, + Volatile = 701, + When = 702, + Where = 703, + WhitespaceP = 704, + Window = 705, + With = 706, + Within = 707, + Without = 708, + Work = 709, + Wrapper = 710, + Write = 711, + XmlP = 712, + Xmlattributes = 713, + Xmlconcat = 714, + Xmlelement = 715, + Xmlexists = 716, + Xmlforest = 717, + Xmlnamespaces = 718, + Xmlparse = 719, + Xmlpi = 720, + Xmlroot = 721, + Xmlserialize = 722, + Xmltable = 723, + YearP = 724, + YesP = 725, + Zone = 726, + NotLa = 727, + NullsLa = 728, + WithLa = 729, + Postfixop = 730, + Uminus = 731, +} diff --git a/src/tools/rustfmt/tests/source/struct_field_doc_comment.rs b/src/tools/rustfmt/tests/source/struct_field_doc_comment.rs new file mode 100644 index 00000000000..191a6210045 --- /dev/null +++ b/src/tools/rustfmt/tests/source/struct_field_doc_comment.rs @@ -0,0 +1,72 @@ +// #5215 +struct MyTuple( + /// Doc Comments + /* TODO note to add more to Doc Comments */ u32, + /// Doc Comments + // TODO note + u64, +); + +struct MyTuple( + #[cfg(unix)] // some comment + u64, + #[cfg(not(unix))] /*block comment */ + u32, +); + +struct MyTuple( + #[cfg(unix)] + // some comment + u64, + #[cfg(not(unix))] + /*block comment */ + u32, +); + +struct MyTuple( + #[cfg(unix)] // some comment + pub u64, + #[cfg(not(unix))] /*block comment */ + pub(crate) u32, +); + +struct MyTuple( + /// Doc Comments + /* TODO note to add more to Doc Comments */ + pub u32, + /// Doc Comments + // TODO note + pub(crate) u64, +); + +struct MyStruct { + #[cfg(unix)] // some comment + a: u64, + #[cfg(not(unix))] /*block comment */ + b: u32, +} + +struct MyStruct { + #[cfg(unix)] // some comment + pub a: u64, + #[cfg(not(unix))] /*block comment */ + pub(crate) b: u32, +} + +struct MyStruct { + /// Doc Comments + /* TODO note to add more to Doc Comments */ + a: u32, + /// Doc Comments + // TODO note + b: u64, +} + +struct MyStruct { + /// Doc Comments + /* TODO note to add more to Doc Comments */ + pub a: u32, + /// Doc Comments + // TODO note + pub(crate) b: u64, +} diff --git a/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs new file mode 100644 index 00000000000..ecc8ede02cc --- /dev/null +++ b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs @@ -0,0 +1,18 @@ +// rustfmt-group_imports: StdExternalCrate +use alloc::alloc::Layout; + +use chrono::Utc; +use juniper::{FieldError, FieldResult}; +use uuid::Uuid; + +use super::update::convert_publish_payload; + +extern crate uuid; + +use core::f32; +use std::sync::Arc; + +use broker::database::PooledConnection; + +use super::schema::{Context, Payload}; +use crate::models::Event; diff --git a/src/tools/rustfmt/tests/target/import-fencepost-length.rs b/src/tools/rustfmt/tests/target/imports/import-fencepost-length.rs similarity index 100% rename from src/tools/rustfmt/tests/target/import-fencepost-length.rs rename to src/tools/rustfmt/tests/target/imports/import-fencepost-length.rs diff --git a/src/tools/rustfmt/tests/target/imports-impl-only-use.rs b/src/tools/rustfmt/tests/target/imports/imports-impl-only-use.rs similarity index 100% rename from src/tools/rustfmt/tests/target/imports-impl-only-use.rs rename to src/tools/rustfmt/tests/target/imports/imports-impl-only-use.rs diff --git a/src/tools/rustfmt/tests/target/imports-reorder-lines-and-items.rs b/src/tools/rustfmt/tests/target/imports/imports-reorder-lines-and-items.rs similarity index 100% rename from src/tools/rustfmt/tests/target/imports-reorder-lines-and-items.rs rename to src/tools/rustfmt/tests/target/imports/imports-reorder-lines-and-items.rs diff --git a/src/tools/rustfmt/tests/target/imports-reorder-lines.rs b/src/tools/rustfmt/tests/target/imports/imports-reorder-lines.rs similarity index 100% rename from src/tools/rustfmt/tests/target/imports-reorder-lines.rs rename to src/tools/rustfmt/tests/target/imports/imports-reorder-lines.rs diff --git a/src/tools/rustfmt/tests/target/imports-reorder.rs b/src/tools/rustfmt/tests/target/imports/imports-reorder.rs similarity index 100% rename from src/tools/rustfmt/tests/target/imports-reorder.rs rename to src/tools/rustfmt/tests/target/imports/imports-reorder.rs diff --git a/src/tools/rustfmt/tests/target/imports.rs b/src/tools/rustfmt/tests/target/imports/imports.rs similarity index 100% rename from src/tools/rustfmt/tests/target/imports.rs rename to src/tools/rustfmt/tests/target/imports/imports.rs diff --git a/src/tools/rustfmt/tests/target/imports_2021_edition.rs b/src/tools/rustfmt/tests/target/imports/imports_2021_edition.rs similarity index 100% rename from src/tools/rustfmt/tests/target/imports_2021_edition.rs rename to src/tools/rustfmt/tests/target/imports/imports_2021_edition.rs diff --git a/src/tools/rustfmt/tests/target/imports_block_indent.rs b/src/tools/rustfmt/tests/target/imports/imports_block_indent.rs similarity index 100% rename from src/tools/rustfmt/tests/target/imports_block_indent.rs rename to src/tools/rustfmt/tests/target/imports/imports_block_indent.rs diff --git a/src/tools/rustfmt/tests/target/imports_granularity_crate.rs b/src/tools/rustfmt/tests/target/imports/imports_granularity_crate.rs similarity index 50% rename from src/tools/rustfmt/tests/target/imports_granularity_crate.rs rename to src/tools/rustfmt/tests/target/imports/imports_granularity_crate.rs index d75906d30f1..36e01558ff0 100644 --- a/src/tools/rustfmt/tests/target/imports_granularity_crate.rs +++ b/src/tools/rustfmt/tests/target/imports/imports_granularity_crate.rs @@ -26,3 +26,34 @@ use j::a::{self}; use k::{a, b, c, d}; use l::{a, b, c, d}; + +use b::q::{self /* After b::q::self */}; +use b::r; // After b::r +use b::s::{ + a, + b, // After b::s::b +}; +use b::t::{/* Before b::t::self */ self}; +use b::t::{ + // Before b::t::a + a, + b, +}; +use b::v::{ + // Before b::v::a + a, + // Before b::v::b + b, +}; +use b::{ + c, d, e, + u::{a, b}, +}; +use b::{ + f::g, + h::{i, j}, /* After b::h group */ +}; +use b::{ + /* Before b::l group */ l::{self, m, n::o, p::*}, + q, +}; diff --git a/src/tools/rustfmt/tests/target/imports/imports_granularity_default-with-dups.rs b/src/tools/rustfmt/tests/target/imports/imports_granularity_default-with-dups.rs new file mode 100644 index 00000000000..5da6d588e6d --- /dev/null +++ b/src/tools/rustfmt/tests/target/imports/imports_granularity_default-with-dups.rs @@ -0,0 +1,6 @@ +use crate::lexer; +use crate::lexer; +use crate::lexer::tokens::TokenData; +use crate::lexer::tokens::TokenData; +use crate::lexer::{self}; +use crate::lexer::{self, tokens::TokenData}; diff --git a/src/tools/rustfmt/tests/target/imports/imports_granularity_item-with-dups-StdExternalCrate-no-reorder.rs b/src/tools/rustfmt/tests/target/imports/imports_granularity_item-with-dups-StdExternalCrate-no-reorder.rs new file mode 100644 index 00000000000..ed4df544d6f --- /dev/null +++ b/src/tools/rustfmt/tests/target/imports/imports_granularity_item-with-dups-StdExternalCrate-no-reorder.rs @@ -0,0 +1,7 @@ +// rustfmt-imports_granularity: Item +// rustfmt-reorder_imports: false +// rustfmt-group_imports: StdExternalCrate + +use crate::lexer; +use crate::lexer::tokens::TokenData; +use crate::lexer::{self}; diff --git a/src/tools/rustfmt/tests/target/imports/imports_granularity_item-with-dups.rs b/src/tools/rustfmt/tests/target/imports/imports_granularity_item-with-dups.rs new file mode 100644 index 00000000000..00df37f9332 --- /dev/null +++ b/src/tools/rustfmt/tests/target/imports/imports_granularity_item-with-dups.rs @@ -0,0 +1,5 @@ +// rustfmt-imports_granularity: Item + +use crate::lexer; +use crate::lexer::tokens::TokenData; +use crate::lexer::{self}; diff --git a/src/tools/rustfmt/tests/target/imports/imports_granularity_item.rs b/src/tools/rustfmt/tests/target/imports/imports_granularity_item.rs new file mode 100644 index 00000000000..d2f5496fdac --- /dev/null +++ b/src/tools/rustfmt/tests/target/imports/imports_granularity_item.rs @@ -0,0 +1,45 @@ +// rustfmt-imports_granularity: Item + +use a::b; +use a::c; +use a::d; +use a::f::g; +use a::h::i; +use a::h::j; +use a::l::m; +use a::l::n::o; +use a::l::p::*; +use a::l::{self}; +use a::q::{self}; + +use b::c; +use b::d; +use b::e; +use b::q::{self /* After b::q::self */}; +use b::r; // After b::r +use b::s::{ + a, + b, // After b::s::b +}; +use b::t::{/* Before b::t::self */ self}; +use b::t::{ + // Before b::t::a + a, + b, +}; +use b::u::a; +use b::u::b; +use b::v::{ + // Before b::v::a + a, + // Before b::v::b + b, +}; +use b::{ + f::g, + h::{i, j}, /* After b::h group */ +}; +use b::{ + /* Before b::l group */ l::{self, m, n::o, p::*}, + q, +}; diff --git a/src/tools/rustfmt/tests/target/imports/imports_granularity_module.rs b/src/tools/rustfmt/tests/target/imports/imports_granularity_module.rs new file mode 100644 index 00000000000..14f341016ff --- /dev/null +++ b/src/tools/rustfmt/tests/target/imports/imports_granularity_module.rs @@ -0,0 +1,55 @@ +// rustfmt-imports_granularity: Module + +use a::b::c; +use a::d::e; +use a::f; +use a::g::{h, i}; +use a::j::k::{self, l}; +use a::j::{self, m}; +use a::n::o::p; +use a::n::q; +pub use a::r::s; +pub use a::t; +use b::c::d; +use b::{self}; + +use foo::e; +#[cfg(test)] +use foo::{a::b, c::d}; + +use bar::{ + // comment + a::b, + // more comment + c::d, + e::f, +}; + +use b::q::{self /* After b::q::self */}; +use b::r; // After b::r +use b::s::{ + a, + b, // After b::s::b +}; +use b::t::{/* Before b::t::self */ self}; +use b::t::{ + // Before b::t::a + a, + b, +}; +use b::u::{a, b}; +use b::v::{ + // Before b::v::a + a, + // Before b::v::b + b, +}; +use b::{c, d, e}; +use b::{ + f::g, + h::{i, j}, /* After b::h group */ +}; +use b::{ + /* Before b::l group */ l::{self, m, n::o, p::*}, + q, +}; diff --git a/src/tools/rustfmt/tests/target/imports_granularity_item.rs b/src/tools/rustfmt/tests/target/imports_granularity_item.rs deleted file mode 100644 index eace785e670..00000000000 --- a/src/tools/rustfmt/tests/target/imports_granularity_item.rs +++ /dev/null @@ -1,13 +0,0 @@ -// rustfmt-imports_granularity: Item - -use a::b; -use a::c; -use a::d; -use a::f::g; -use a::h::i; -use a::h::j; -use a::l::m; -use a::l::n::o; -use a::l::p::*; -use a::l::{self}; -use a::q::{self}; diff --git a/src/tools/rustfmt/tests/target/imports_granularity_module.rs b/src/tools/rustfmt/tests/target/imports_granularity_module.rs deleted file mode 100644 index e4e1a299e58..00000000000 --- a/src/tools/rustfmt/tests/target/imports_granularity_module.rs +++ /dev/null @@ -1,22 +0,0 @@ -// rustfmt-imports_granularity: Module - -use a::b::c; -use a::d::e; -use a::f; -use a::g::{h, i}; -use a::j::k::{self, l}; -use a::j::{self, m}; -use a::n::o::p; -use a::n::q; -pub use a::r::s; -pub use a::t; -use b::c::d; -use b::{self}; - -use foo::e; -#[cfg(test)] -use foo::{a::b, c::d}; - -use bar::a::b; -use bar::c::d; -use bar::e::f; diff --git a/src/tools/rustfmt/tests/target/imports_granularity_one.rs b/src/tools/rustfmt/tests/target/imports_granularity_one.rs index 78ec5e7325c..da4c6678db1 100644 --- a/src/tools/rustfmt/tests/target/imports_granularity_one.rs +++ b/src/tools/rustfmt/tests/target/imports_granularity_one.rs @@ -68,12 +68,42 @@ use { c::{self, ca}, }; -use { - a::{ - aa::{aaa, aab}, - ab, - ac::aca, - ad::ada, - }, - b as x, +use a::{ + // some comment + aa::{aaa, aab}, + ab, + // another comment + ac::aca, +}; +use {a::ad::ada, b as x}; + +use b::q::{self /* After b::q::self */}; +use b::r; // After b::r +use b::s::{ + a, + b, // After b::s::b +}; +use b::t::{/* Before b::t::self */ self}; +use b::t::{ + // Before b::t::a + a, + b, +}; +use b::v::{ + // Before b::v::a + a, + // Before b::v::b + b, +}; +use b::{ + c, d, e, + u::{a, b}, +}; +use b::{ + f::g, + h::{i, j}, /* After b::h group */ +}; +use b::{ + /* Before b::l group */ l::{self, m, n::o, p::*}, + q, }; diff --git a/src/tools/rustfmt/tests/target/issue-5030.rs b/src/tools/rustfmt/tests/target/issue-5030.rs new file mode 100644 index 00000000000..8ac3888bdbe --- /dev/null +++ b/src/tools/rustfmt/tests/target/issue-5030.rs @@ -0,0 +1,21 @@ +// rustfmt-imports_granularity: Item +// rustfmt-group_imports: One + +// Confirm that attributes are duplicated to all items in the use statement +#[cfg(feature = "foo")] +use std::collections::HashMap; +#[cfg(feature = "foo")] +use std::collections::HashSet; + +// Separate the imports below from the ones above +const A: usize = 0; + +// Copying attrs works with import grouping as well +#[cfg(feature = "spam")] +use qux::bar; +#[cfg(feature = "spam")] +use qux::baz; +#[cfg(feature = "foo")] +use std::collections::HashMap; +#[cfg(feature = "foo")] +use std::collections::HashSet; diff --git a/src/tools/rustfmt/tests/target/issue-5260.rs b/src/tools/rustfmt/tests/target/issue-5260.rs new file mode 100644 index 00000000000..171f6fa51b7 --- /dev/null +++ b/src/tools/rustfmt/tests/target/issue-5260.rs @@ -0,0 +1,13 @@ +// rustfmt-wrap_comments: true + +/// [MyType](VeryLongPathToMyType::NoLineBreak::Here::Okay::ThatWouldBeNice::Thanks) +fn documented_with_longtype() { + // # We're using a long type link, rustfmt should not break line + // on the type when `wrap_comments = true` +} + +/// VeryLongPathToMyType::JustMyType::But::VeryVery::Long::NoLineBreak::Here::Okay::ThatWouldBeNice::Thanks +fn documented_with_verylongtype() { + // # We're using a long type link, rustfmt should not break line + // on the type when `wrap_comments = true` +} diff --git a/src/tools/rustfmt/tests/target/issue_3937.rs b/src/tools/rustfmt/tests/target/issue_3937.rs new file mode 100644 index 00000000000..80673108500 --- /dev/null +++ b/src/tools/rustfmt/tests/target/issue_3937.rs @@ -0,0 +1,13 @@ +// rustfmt-format_code_in_doc_comments:true + +struct Foo { + // a: i32, + // + // b: i32, +} + +struct Foo { + a: i32, + // + // b: i32, +} diff --git a/src/tools/rustfmt/tests/target/issue_4573.rs b/src/tools/rustfmt/tests/target/issue_4573.rs new file mode 100644 index 00000000000..82cfe4f5359 --- /dev/null +++ b/src/tools/rustfmt/tests/target/issue_4573.rs @@ -0,0 +1,245 @@ +// rustmft-version:Two +// rustmft-use_small_heuristics:Max +// rustmft-merge_derives:false +// These are the same rustfmt configuration options that are used +// in the comiler as of ce39461ca75a and 8eb7c58dbb7b +// These are commits in https://github.com/rust-lang/rust + +#![no_std] // inner attribute comment +// inner attribute comment +#![no_implicit_prelude] +// post inner attribute comment + +#[cfg(not(miri))] // inline comment +#[no_link] +extern crate foo; + +// before attributes +#[no_link] +// between attributes +#[cfg(not(miri))] // inline comment +extern crate foo as bar; + +#[cfg(not(miri))] // inline comment +// between attribute and use +use foo; + +#[cfg(not(miri))] // inline comment +use foo; + +/* pre attributre */ +#[cfg(not(miri))] +use foo::bar; + +#[cfg(not(miri))] // inline comment +use foo::bar as FooBar; + +#[cfg(not(miri))] // inline comment +#[allow(unused)] +#[deprecated( + since = "5.2", // inline inner comment + note = "FOO was rarely used. Users should instead use BAR" +)] +#[allow(unused)] +static FOO: i32 = 42; + +#[used] +#[export_name = "FOO"] +#[cfg(not(miri))] // inline comment +#[deprecated( + since = "5.2", + note = "FOO was rarely used. Users should instead use BAR" +)] +static FOO: i32 = 42; + +#[cfg(not(miri))] // inline comment +#[export_name = "FOO"] +static BAR: &'static str = "bar"; + +#[cfg(not(miri))] // inline comment +const BAR: i32 = 42; + +#[cfg(not(miri))] // inline comment +#[no_mangle] +#[link_section = ".example_section"] +fn foo(bar: usize) { + #[cfg(not(miri))] // inline comment + println!("hello world!"); +} + +#[cfg(not(miri))] // inline comment +mod foo {} + +#[cfg(not(miri))] // inline comment +extern "C" { + fn my_c_function(x: i32) -> bool; +} + +#[cfg(not(miri))] // inline comment +#[link(name = "CoreFoundation", kind = "framework")] +extern "C" { + + #[link_name = "actual_symbol_name"] // inline comment + // between attribute and function + fn my_c_function(x: i32) -> bool; +} + +#[cfg(not(miri))] // inline comment +pub extern "C" fn callable_from_c(x: i32) -> bool { + x % 3 == 0 +} + +#[cfg(not(miri))] // inline comment +/* between attribute block comment */ +#[no_mangle] +/* between attribute and type */ +type Foo = Bar; + +#[no_mangle] +#[cfg(not(miri))] // inline comment +#[non_exhaustive] // inline comment +enum Foo { + Bar, + Baz, +} + +#[no_mangle] +#[cfg(not(miri))] /* inline comment */ +struct Foo { + x: A, +} + +#[cfg(not(miri))] // inline comment +union Foo { + x: A, + y: B, +} + +#[cfg(not(miri))] // inline comment +trait Foo {} + +#[cfg(not(miri))] // inline comment +trait Foo = Bar + Quux; + +#[cfg(not(miri))] // inline comment +impl Foo {} + +#[cfg(not(miri))] // inline comment +macro_rules! bar { + (3) => {}; +} + +mod nested { + #[cfg(not(miri))] // inline comment + // between attribute and use + use foo; + + #[cfg(not(miri))] // inline comment + use foo; + + #[cfg(not(miri))] // inline comment + use foo::bar; + + #[cfg(not(miri))] // inline comment + use foo::bar as FooBar; + + #[cfg(not(miri))] // inline comment + static FOO: i32 = 42; + + #[cfg(not(miri))] // inline comment + static FOO: i32 = 42; + + #[cfg(not(miri))] // inline comment + static FOO: &'static str = "bar"; + + #[cfg(not(miri))] // inline comment + const FOO: i32 = 42; + + #[cfg(not(miri))] // inline comment + fn foo(bar: usize) { + #[cfg(not(miri))] // inline comment + println!("hello world!"); + } + + #[cfg(not(miri))] // inline comment + mod foo {} + + #[cfg(not(miri))] // inline comment + mod foo {} + + #[cfg(not(miri))] // inline comment + extern "C" { + fn my_c_function(x: i32) -> bool; + } + + #[cfg(not(miri))] // inline comment + #[link(name = "CoreFoundation", kind = "framework")] + extern "C" { + + #[link_name = "actual_symbol_name"] // inline comment + // between attribute and function + fn my_c_function(x: i32) -> bool; + } + + #[cfg(not(miri))] // inline comment + pub extern "C" fn callable_from_c(x: i32) -> bool { + x % 3 == 0 + } + + #[cfg(not(miri))] // inline comment + type Foo = Bar; + + #[cfg(not(miri))] // inline comment + #[non_exhaustive] // inline comment + enum Foo { + // comment + #[attribute_1] + #[attribute_2] // comment + // comment! + Bar, + /* comment */ + #[attribute_1] + #[attribute_2] /* comment */ + #[attribute_3] + #[attribute_4] + /* comment! */ + Baz, + } + + #[cfg(not(miri))] // inline comment + struct Foo { + x: A, + } + + #[cfg(not(miri))] // inline comment + union Foo { + #[attribute_1] + #[attribute_2] /* comment */ + #[attribute_3] + #[attribute_4] // comment + x: A, + y: B, + } + + #[cfg(not(miri))] // inline comment + #[allow(missing_docs)] + trait Foo { + #[must_use] /* comment + * that wrappes to + * the next line */ + fn bar() {} + } + + #[allow(missing_docs)] + #[cfg(not(miri))] // inline comment + trait Foo = Bar + Quux; + + #[allow(missing_docs)] + #[cfg(not(miri))] // inline comment + impl Foo {} + + #[cfg(not(miri))] // inline comment + macro_rules! bar { + (3) => {}; + } +} diff --git a/src/tools/rustfmt/tests/target/license-templates/empty_license_path.rs b/src/tools/rustfmt/tests/target/license-templates/empty_license_path.rs deleted file mode 100644 index 950f103ed39..00000000000 --- a/src/tools/rustfmt/tests/target/license-templates/empty_license_path.rs +++ /dev/null @@ -1,5 +0,0 @@ -// rustfmt-config: issue-3802.toml - -fn main() { - println!("Hello world!"); -} diff --git a/src/tools/rustfmt/tests/target/license-templates/license.rs b/src/tools/rustfmt/tests/target/license-templates/license.rs deleted file mode 100644 index 7169c7b2576..00000000000 --- a/src/tools/rustfmt/tests/target/license-templates/license.rs +++ /dev/null @@ -1,6 +0,0 @@ -// rustfmt-license_template_path: tests/license-template/lt.txt -// Copyright 2019 The rustfmt developers. - -fn main() { - println!("Hello world!"); -} diff --git a/src/tools/rustfmt/tests/target/performance/issue-4476.rs b/src/tools/rustfmt/tests/target/performance/issue-4476.rs new file mode 100644 index 00000000000..30567f2644b --- /dev/null +++ b/src/tools/rustfmt/tests/target/performance/issue-4476.rs @@ -0,0 +1,705 @@ +use super::SemverParser; + +#[allow(dead_code, non_camel_case_types)] +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum Rule { + EOI, + range_set, + logical_or, + range, + empty, + hyphen, + simple, + primitive, + primitive_op, + partial, + xr, + xr_op, + nr, + tilde, + caret, + qualifier, + parts, + part, + space, +} +#[allow(clippy::all)] +impl ::pest::Parser for SemverParser { + fn parse<'i>( + rule: Rule, + input: &'i str, + ) -> ::std::result::Result<::pest::iterators::Pairs<'i, Rule>, ::pest::error::Error> { + mod rules { + pub mod hidden { + use super::super::Rule; + #[inline] + #[allow(dead_code, non_snake_case, unused_variables)] + pub fn skip( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + Ok(state) + } + } + pub mod visible { + use super::super::Rule; + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn range_set( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::range_set, |state| { + state.sequence(|state| { + self::SOI(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::range(state)) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + state + .sequence(|state| { + self::logical_or(state) + .and_then(|state| { + super::hidden::skip(state) + }) + .and_then(|state| self::range(state)) + }) + .and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then( + |state| { + state.sequence(|state| { + self::logical_or(state) + .and_then(|state| { + super::hidden::skip( + state, + ) + }) + .and_then(|state| { + self::range(state) + }) + }) + }, + ) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::EOI(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn logical_or( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::logical_or, |state| { + state.sequence(|state| { + state + .sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| state.match_string("||")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn range( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::range, |state| { + self::hyphen(state) + .or_else(|state| { + state.sequence(|state| { + self::simple(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + state + .sequence(|state| { + state + .optional(|state| { + state.match_string(",") + }) + .and_then(|state| { + super::hidden::skip(state) + }) + .and_then(|state| { + state.sequence(|state| { + self::space(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + }) + }) + .and_then(|state| { + super::hidden::skip(state) + }) + .and_then(|state| { + self::simple(state) + }) + }) + .and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| { + state.sequence( + |state| { + state + .optional(|state| state.match_string(",")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + self::space(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::simple(state)) + }, + ) + }) + }) + }) + }) + }) + }) + }) + }) + }) + .or_else(|state| self::empty(state)) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn empty( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::empty, |state| state.match_string("")) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn hyphen( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::hyphen, |state| { + state.sequence(|state| { + self::partial(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + self::space(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| { + self::space(state) + }) + }) + }) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| state.match_string("-")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + self::space(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| { + self::space(state) + }) + }) + }) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::partial(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn simple( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::simple, |state| { + self::primitive(state) + .or_else(|state| self::partial(state)) + .or_else(|state| self::tilde(state)) + .or_else(|state| self::caret(state)) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn primitive( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::primitive, |state| { + state.sequence(|state| { + self::primitive_op(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::partial(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn primitive_op( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::primitive_op, |state| { + state + .match_string("<=") + .or_else(|state| state.match_string(">=")) + .or_else(|state| state.match_string(">")) + .or_else(|state| state.match_string("<")) + .or_else(|state| state.match_string("=")) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn partial( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::partial, |state| { + state.sequence(|state| { + self::xr(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.optional(|state| { + state.sequence(|state| { + state + .match_string(".") + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::xr(state)) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.optional(|state| { + state.sequence(|state| { + state + .match_string(".") + .and_then(|state| { + super::hidden::skip(state) + }) + .and_then(|state| self::xr(state)) + .and_then(|state| { + super::hidden::skip(state) + }) + .and_then(|state| { + state.optional(|state| { + self::qualifier(state) + }) + }) + }) + }) + }) + }) + }) + }) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn xr( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::xr, |state| { + self::xr_op(state).or_else(|state| self::nr(state)) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn xr_op( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::xr_op, |state| { + state + .match_string("x") + .or_else(|state| state.match_string("X")) + .or_else(|state| state.match_string("*")) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn nr( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::nr, |state| { + state.match_string("0").or_else(|state| { + state.sequence(|state| { + state + .match_range('1'..'9') + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + state.match_range('0'..'9').and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then( + |state| state.match_range('0'..'9'), + ) + }) + }) + }) + }) + }) + }) + }) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn tilde( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::tilde, |state| { + state.sequence(|state| { + state + .match_string("~>") + .or_else(|state| state.match_string("~")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::partial(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn caret( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::caret, |state| { + state.sequence(|state| { + state + .match_string("^") + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + self::space(state).and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state) + .and_then(|state| self::space(state)) + }) + }) + }) + }) + }) + }) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::partial(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn qualifier( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::qualifier, |state| { + state.sequence(|state| { + state + .match_string("-") + .or_else(|state| state.match_string("+")) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| self::parts(state)) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn parts( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::parts, |state| { + state.sequence(|state| { + self::part(state) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + state + .sequence(|state| { + state + .match_string(".") + .and_then(|state| { + super::hidden::skip(state) + }) + .and_then(|state| self::part(state)) + }) + .and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then( + |state| { + state.sequence(|state| { + state + .match_string(".") + .and_then(|state| { + super::hidden::skip( + state, + ) + }) + .and_then(|state| { + self::part(state) + }) + }) + }, + ) + }) + }) + }) + }) + }) + }) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn part( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::part, |state| { + self::nr(state).or_else(|state| { + state.sequence(|state| { + state + .match_string("-") + .or_else(|state| state.match_range('0'..'9')) + .or_else(|state| state.match_range('A'..'Z')) + .or_else(|state| state.match_range('a'..'z')) + .and_then(|state| super::hidden::skip(state)) + .and_then(|state| { + state.sequence(|state| { + state.optional(|state| { + state + .match_string("-") + .or_else(|state| state.match_range('0'..'9')) + .or_else(|state| state.match_range('A'..'Z')) + .or_else(|state| state.match_range('a'..'z')) + .and_then(|state| { + state.repeat(|state| { + state.sequence(|state| { + super::hidden::skip(state).and_then( + |state| { + state + .match_string("-") + .or_else(|state| { + state.match_range( + '0'..'9', + ) + }) + .or_else(|state| { + state.match_range( + 'A'..'Z', + ) + }) + .or_else(|state| { + state.match_range( + 'a'..'z', + ) + }) + }, + ) + }) + }) + }) + }) + }) + }) + }) + }) + }) + } + #[inline] + #[allow(non_snake_case, unused_variables)] + pub fn space( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state + .match_string(" ") + .or_else(|state| state.match_string("\t")) + } + #[inline] + #[allow(dead_code, non_snake_case, unused_variables)] + pub fn EOI( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.rule(Rule::EOI, |state| state.end_of_input()) + } + #[inline] + #[allow(dead_code, non_snake_case, unused_variables)] + pub fn SOI( + state: Box<::pest::ParserState>, + ) -> ::pest::ParseResult>> { + state.start_of_input() + } + } + pub use self::visible::*; + } + ::pest::state(input, |state| match rule { + Rule::range_set => rules::range_set(state), + Rule::logical_or => rules::logical_or(state), + Rule::range => rules::range(state), + Rule::empty => rules::empty(state), + Rule::hyphen => rules::hyphen(state), + Rule::simple => rules::simple(state), + Rule::primitive => rules::primitive(state), + Rule::primitive_op => rules::primitive_op(state), + Rule::partial => rules::partial(state), + Rule::xr => rules::xr(state), + Rule::xr_op => rules::xr_op(state), + Rule::nr => rules::nr(state), + Rule::tilde => rules::tilde(state), + Rule::caret => rules::caret(state), + Rule::qualifier => rules::qualifier(state), + Rule::parts => rules::parts(state), + Rule::part => rules::part(state), + Rule::space => rules::space(state), + Rule::EOI => rules::EOI(state), + }) + } +} diff --git a/src/tools/rustfmt/tests/target/performance/issue-4867.rs b/src/tools/rustfmt/tests/target/performance/issue-4867.rs new file mode 100644 index 00000000000..336dae1b64a --- /dev/null +++ b/src/tools/rustfmt/tests/target/performance/issue-4867.rs @@ -0,0 +1,13 @@ +mod modA { + mod modB { + mod modC { + mod modD { + mod modE { + fn func() { + state . rule (Rule :: myrule , | state | { state . sequence (| state | { state . sequence (| state | { state . match_string ("abc") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . match_string ("def") }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { state . sequence (| state | { state . match_string ("abc") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . match_string ("def") }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { state . sequence (| state | { state . match_string ("abc") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . match_string ("def") }) }) }) }) }) }) }) }) }) }) }); + } + } + } + } + } +} diff --git a/src/tools/rustfmt/tests/target/performance/issue-5128.rs b/src/tools/rustfmt/tests/target/performance/issue-5128.rs new file mode 100644 index 00000000000..ba9ebfc6243 --- /dev/null +++ b/src/tools/rustfmt/tests/target/performance/issue-5128.rs @@ -0,0 +1,4898 @@ +fn takes_a_long_time_to_rustfmt() { + let inner_cte = vec![Node { + node: Some(node::Node::CommonTableExpr(Box::new(CommonTableExpr { + ctename: String::from("ranked_by_age_within_key"), + aliascolnames: vec![], + ctematerialized: CteMaterialize::Default as i32, + ctequery: Some(Box::new(Node { + node: Some(node::Node::SelectStmt(Box::new(SelectStmt { + distinct_clause: vec![], + into_clause: None, + target_list: vec![ + Node { + node: Some(node::Node::ResTarget(Box::new(ResTarget { + name: String::from(""), + indirection: vec![], + val: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::AStar(AStar {})), + }], + location: 80, + })), + })), + location: 80, + }))), + }, + Node { + node: Some(node::Node::ResTarget(Box::new(ResTarget { + name: String::from("rank_in_key"), + indirection: vec![], + val: Some(Box::new(Node { + node: Some(node::Node::FuncCall(Box::new(FuncCall { + funcname: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("row_number"), + })), + }], + args: vec![], + agg_order: vec![], + agg_filter: None, + agg_within_group: false, + agg_star: false, + agg_distinct: false, + func_variadic: false, + over: Some(Box::new(WindowDef { + name: String::from(""), + refname: String::from(""), + partition_clause: vec![Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("synthetic_key"), + })), + }], + location: 123, + })), + }], + order_clause: vec![Node { + node: Some(node::Node::SortBy(Box::new(SortBy { + node: Some(Box::new(Node { + node: Some(node::Node::ColumnRef( + ColumnRef { + fields: vec![Node { + node: Some(node::Node::String( + String2 { + str: String::from( + "logical_timestamp", + ), + }, + )), + }], + location: 156, + }, + )), + })), + sortby_dir: SortByDir::SortbyDesc as i32, + sortby_nulls: SortByNulls::SortbyNullsDefault + as i32, + use_op: vec![], + location: -1, + }))), + }], + frame_options: 1058, + start_offset: None, + end_offset: None, + location: 109, + })), + location: 91, + }))), + })), + location: 91, + }))), + }, + ], + from_clause: vec![Node { + node: Some(node::Node::RangeVar(RangeVar { + catalogname: String::from(""), + schemaname: String::from("_supertables"), + relname: String::from("9999-9999-9999"), + inh: true, + relpersistence: String::from("p"), + alias: None, + location: 206, + })), + }], + where_clause: Some(Box::new(Node { + node: Some(node::Node::AExpr(Box::new(AExpr { + kind: AExprKind::AexprOp as i32, + name: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("<="), + })), + }], + lexpr: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("logical_timestamp"), + })), + }], + location: 250, + })), + })), + rexpr: Some(Box::new(Node { + node: Some(node::Node::AConst(Box::new(AConst { + val: Some(Box::new(Node { + node: Some(node::Node::Integer(Integer { ival: 9000 })), + })), + location: 271, + }))), + })), + location: 268, + }))), + })), + group_clause: vec![], + having_clause: None, + window_clause: vec![], + values_lists: vec![], + sort_clause: vec![], + limit_offset: None, + limit_count: None, + limit_option: LimitOption::Default as i32, + locking_clause: vec![], + with_clause: None, + op: SetOperation::SetopNone as i32, + all: false, + larg: None, + rarg: None, + }))), + })), + location: 29, + cterecursive: false, + cterefcount: 0, + ctecolnames: vec![], + ctecoltypes: vec![], + ctecoltypmods: vec![], + ctecolcollations: vec![], + }))), + }]; + let outer_cte = vec![Node { + node: Some(node::Node::CommonTableExpr(Box::new(CommonTableExpr { + ctename: String::from("table_name"), + aliascolnames: vec![], + ctematerialized: CteMaterialize::Default as i32, + ctequery: Some(Box::new(Node { + node: Some(node::Node::SelectStmt(Box::new(SelectStmt { + distinct_clause: vec![], + into_clause: None, + target_list: vec![ + Node { + node: Some(node::Node::ResTarget(Box::new(ResTarget { + name: String::from("column1"), + indirection: vec![], + val: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("c1"), + })), + }], + location: 301, + })), + })), + location: 301, + }))), + }, + Node { + node: Some(node::Node::ResTarget(Box::new(ResTarget { + name: String::from("column2"), + indirection: vec![], + val: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("c2"), + })), + }], + location: 324, + })), + })), + location: 324, + }))), + }, + ], + from_clause: vec![Node { + node: Some(node::Node::RangeVar(RangeVar { + catalogname: String::from(""), + schemaname: String::from(""), + relname: String::from("ranked_by_age_within_key"), + inh: true, + relpersistence: String::from("p"), + alias: None, + location: 347, + })), + }], + where_clause: Some(Box::new(Node { + node: Some(node::Node::BoolExpr(Box::new(BoolExpr { + xpr: None, + boolop: BoolExprType::AndExpr as i32, + args: vec![ + Node { + node: Some(node::Node::AExpr(Box::new(AExpr { + kind: AExprKind::AexprOp as i32, + name: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("="), + })), + }], + lexpr: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("rank_in_key"), + })), + }], + location: 382, + })), + })), + rexpr: Some(Box::new(Node { + node: Some(node::Node::AConst(Box::new(AConst { + val: Some(Box::new(Node { + node: Some(node::Node::Integer(Integer { + ival: 1, + })), + })), + location: 396, + }))), + })), + location: 394, + }))), + }, + Node { + node: Some(node::Node::AExpr(Box::new(AExpr { + kind: AExprKind::AexprOp as i32, + name: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("="), + })), + }], + lexpr: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("is_deleted"), + })), + }], + location: 402, + })), + })), + rexpr: Some(Box::new(Node { + node: Some(node::Node::TypeCast(Box::new(TypeCast { + arg: Some(Box::new(Node { + node: Some(node::Node::AConst(Box::new( + AConst { + val: Some(Box::new(Node { + node: Some(node::Node::String( + String2 { + str: String::from("f"), + }, + )), + })), + location: 415, + }, + ))), + })), + type_name: Some(TypeName { + names: vec![ + Node { + node: Some(node::Node::String( + String2 { + str: String::from("pg_catalog"), + }, + )), + }, + Node { + node: Some(node::Node::String( + String2 { + str: String::from("bool"), + }, + )), + }, + ], + type_oid: 0, + setof: false, + pct_type: false, + typmods: vec![], + typemod: -1, + array_bounds: vec![], + location: -1, + }), + location: -1, + }))), + })), + location: 413, + }))), + }, + ], + location: 398, + }))), + })), + group_clause: vec![], + having_clause: None, + window_clause: vec![], + values_lists: vec![], + sort_clause: vec![], + limit_offset: None, + limit_count: None, + limit_option: LimitOption::Default as i32, + locking_clause: vec![], + with_clause: Some(WithClause { + ctes: inner_cte, + recursive: false, + location: 24, + }), + op: SetOperation::SetopNone as i32, + all: false, + larg: None, + rarg: None, + }))), + })), + location: 5, + cterecursive: false, + cterefcount: 0, + ctecolnames: vec![], + ctecoltypes: vec![], + ctecoltypmods: vec![], + ctecolcollations: vec![], + }))), + }]; + let expected_result = ParseResult { + version: 130003, + stmts: vec![RawStmt { + stmt: Some(Box::new(Node { + node: Some(node::Node::SelectStmt(Box::new(SelectStmt { + distinct_clause: vec![], + into_clause: None, + + target_list: vec![Node { + node: Some(node::Node::ResTarget(Box::new(ResTarget { + name: String::from(""), + indirection: vec![], + val: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("column1"), + })), + }], + location: 430, + })), + })), + location: 430, + }))), + }], + from_clause: vec![Node { + node: Some(node::Node::RangeVar(RangeVar { + catalogname: String::from(""), + schemaname: String::from(""), + relname: String::from("table_name"), + inh: true, + relpersistence: String::from("p"), + alias: None, + location: 443, + })), + }], + where_clause: Some(Box::new(Node { + node: Some(node::Node::AExpr(Box::new(AExpr { + kind: AExprKind::AexprOp as i32, + name: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from(">"), + })), + }], + lexpr: Some(Box::new(Node { + node: Some(node::Node::ColumnRef(ColumnRef { + fields: vec![Node { + node: Some(node::Node::String(String2 { + str: String::from("column2"), + })), + }], + location: 460, + })), + })), + rexpr: Some(Box::new(Node { + node: Some(node::Node::AConst(Box::new(AConst { + val: Some(Box::new(Node { + node: Some(node::Node::Integer(Integer { ival: 9000 })), + })), + location: 470, + }))), + })), + location: 468, + }))), + })), + group_clause: vec![], + having_clause: None, + window_clause: vec![], + values_lists: vec![], + sort_clause: vec![], + limit_offset: None, + limit_count: None, + limit_option: LimitOption::Default as i32, + locking_clause: vec![], + with_clause: Some(WithClause { + ctes: outer_cte, + recursive: false, + location: 0, + }), + op: SetOperation::SetopNone as i32, + all: false, + larg: None, + rarg: None, + }))), + })), + stmt_location: 0, + stmt_len: 0, + }], + }; +} +#[derive(Clone, PartialEq)] +pub struct ParseResult { + pub version: i32, + + pub stmts: Vec, +} +#[derive(Clone, PartialEq)] +pub struct ScanResult { + pub version: i32, + + pub tokens: Vec, +} +#[derive(Clone, PartialEq)] +pub struct Node { + pub node: ::core::option::Option, +} +/// Nested message and enum types in `Node`. +pub mod node { + #[derive(Clone, PartialEq)] + pub enum Node { + Alias(super::Alias), + + RangeVar(super::RangeVar), + + TableFunc(Box), + + Expr(super::Expr), + + Var(Box), + + Param(Box), + + Aggref(Box), + + GroupingFunc(Box), + + WindowFunc(Box), + + SubscriptingRef(Box), + + FuncExpr(Box), + + NamedArgExpr(Box), + + OpExpr(Box), + + DistinctExpr(Box), + + NullIfExpr(Box), + + ScalarArrayOpExpr(Box), + + BoolExpr(Box), + + SubLink(Box), + + SubPlan(Box), + + AlternativeSubPlan(Box), + + FieldSelect(Box), + + FieldStore(Box), + + RelabelType(Box), + + CoerceViaIo(Box), + + ArrayCoerceExpr(Box), + + ConvertRowtypeExpr(Box), + + CollateExpr(Box), + + CaseExpr(Box), + + CaseWhen(Box), + + CaseTestExpr(Box), + + ArrayExpr(Box), + + RowExpr(Box), + + RowCompareExpr(Box), + + CoalesceExpr(Box), + + MinMaxExpr(Box), + + SqlvalueFunction(Box), + + XmlExpr(Box), + + NullTest(Box), + + BooleanTest(Box), + + CoerceToDomain(Box), + + CoerceToDomainValue(Box), + + SetToDefault(Box), + + CurrentOfExpr(Box), + + NextValueExpr(Box), + + InferenceElem(Box), + + TargetEntry(Box), + + RangeTblRef(super::RangeTblRef), + + JoinExpr(Box), + + FromExpr(Box), + + OnConflictExpr(Box), + + IntoClause(Box), + + RawStmt(Box), + + Query(Box), + + InsertStmt(Box), + + DeleteStmt(Box), + + UpdateStmt(Box), + + SelectStmt(Box), + + AlterTableStmt(super::AlterTableStmt), + + AlterTableCmd(Box), + + AlterDomainStmt(Box), + + SetOperationStmt(Box), + + GrantStmt(super::GrantStmt), + + GrantRoleStmt(super::GrantRoleStmt), + + AlterDefaultPrivilegesStmt(super::AlterDefaultPrivilegesStmt), + + ClosePortalStmt(super::ClosePortalStmt), + + ClusterStmt(super::ClusterStmt), + + CopyStmt(Box), + + CreateStmt(super::CreateStmt), + + DefineStmt(super::DefineStmt), + + DropStmt(super::DropStmt), + + TruncateStmt(super::TruncateStmt), + + CommentStmt(Box), + + FetchStmt(super::FetchStmt), + + IndexStmt(Box), + + CreateFunctionStmt(super::CreateFunctionStmt), + + AlterFunctionStmt(super::AlterFunctionStmt), + + DoStmt(super::DoStmt), + + RenameStmt(Box), + + RuleStmt(Box), + + NotifyStmt(super::NotifyStmt), + + ListenStmt(super::ListenStmt), + + UnlistenStmt(super::UnlistenStmt), + + TransactionStmt(super::TransactionStmt), + + ViewStmt(Box), + + LoadStmt(super::LoadStmt), + + CreateDomainStmt(Box), + + CreatedbStmt(super::CreatedbStmt), + + DropdbStmt(super::DropdbStmt), + + VacuumStmt(super::VacuumStmt), + + ExplainStmt(Box), + + CreateTableAsStmt(Box), + + CreateSeqStmt(super::CreateSeqStmt), + + AlterSeqStmt(super::AlterSeqStmt), + + VariableSetStmt(super::VariableSetStmt), + + VariableShowStmt(super::VariableShowStmt), + + DiscardStmt(super::DiscardStmt), + + CreateTrigStmt(Box), + + CreatePlangStmt(super::CreatePLangStmt), + + CreateRoleStmt(super::CreateRoleStmt), + + AlterRoleStmt(super::AlterRoleStmt), + + DropRoleStmt(super::DropRoleStmt), + + LockStmt(super::LockStmt), + + ConstraintsSetStmt(super::ConstraintsSetStmt), + + ReindexStmt(super::ReindexStmt), + + CheckPointStmt(super::CheckPointStmt), + + CreateSchemaStmt(super::CreateSchemaStmt), + + AlterDatabaseStmt(super::AlterDatabaseStmt), + + AlterDatabaseSetStmt(super::AlterDatabaseSetStmt), + + AlterRoleSetStmt(super::AlterRoleSetStmt), + + CreateConversionStmt(super::CreateConversionStmt), + + CreateCastStmt(super::CreateCastStmt), + + CreateOpClassStmt(super::CreateOpClassStmt), + + CreateOpFamilyStmt(super::CreateOpFamilyStmt), + + AlterOpFamilyStmt(super::AlterOpFamilyStmt), + + PrepareStmt(Box), + + ExecuteStmt(super::ExecuteStmt), + + DeallocateStmt(super::DeallocateStmt), + + DeclareCursorStmt(Box), + + CreateTableSpaceStmt(super::CreateTableSpaceStmt), + + DropTableSpaceStmt(super::DropTableSpaceStmt), + + AlterObjectDependsStmt(Box), + + AlterObjectSchemaStmt(Box), + + AlterOwnerStmt(Box), + + AlterOperatorStmt(super::AlterOperatorStmt), + + AlterTypeStmt(super::AlterTypeStmt), + + DropOwnedStmt(super::DropOwnedStmt), + + ReassignOwnedStmt(super::ReassignOwnedStmt), + + CompositeTypeStmt(super::CompositeTypeStmt), + + CreateEnumStmt(super::CreateEnumStmt), + + CreateRangeStmt(super::CreateRangeStmt), + + AlterEnumStmt(super::AlterEnumStmt), + + AlterTsdictionaryStmt(super::AlterTsDictionaryStmt), + + AlterTsconfigurationStmt(super::AlterTsConfigurationStmt), + + CreateFdwStmt(super::CreateFdwStmt), + + AlterFdwStmt(super::AlterFdwStmt), + + CreateForeignServerStmt(super::CreateForeignServerStmt), + + AlterForeignServerStmt(super::AlterForeignServerStmt), + + CreateUserMappingStmt(super::CreateUserMappingStmt), + + AlterUserMappingStmt(super::AlterUserMappingStmt), + + DropUserMappingStmt(super::DropUserMappingStmt), + + AlterTableSpaceOptionsStmt(super::AlterTableSpaceOptionsStmt), + + AlterTableMoveAllStmt(super::AlterTableMoveAllStmt), + + SecLabelStmt(Box), + + CreateForeignTableStmt(super::CreateForeignTableStmt), + + ImportForeignSchemaStmt(super::ImportForeignSchemaStmt), + + CreateExtensionStmt(super::CreateExtensionStmt), + + AlterExtensionStmt(super::AlterExtensionStmt), + + AlterExtensionContentsStmt(Box), + + CreateEventTrigStmt(super::CreateEventTrigStmt), + + AlterEventTrigStmt(super::AlterEventTrigStmt), + + RefreshMatViewStmt(super::RefreshMatViewStmt), + + ReplicaIdentityStmt(super::ReplicaIdentityStmt), + + AlterSystemStmt(super::AlterSystemStmt), + + CreatePolicyStmt(Box), + + AlterPolicyStmt(Box), + + CreateTransformStmt(super::CreateTransformStmt), + + CreateAmStmt(super::CreateAmStmt), + + CreatePublicationStmt(super::CreatePublicationStmt), + + AlterPublicationStmt(super::AlterPublicationStmt), + + CreateSubscriptionStmt(super::CreateSubscriptionStmt), + + AlterSubscriptionStmt(super::AlterSubscriptionStmt), + + DropSubscriptionStmt(super::DropSubscriptionStmt), + + CreateStatsStmt(super::CreateStatsStmt), + + AlterCollationStmt(super::AlterCollationStmt), + + CallStmt(Box), + + AlterStatsStmt(super::AlterStatsStmt), + + AExpr(Box), + + ColumnRef(super::ColumnRef), + + ParamRef(super::ParamRef), + + AConst(Box), + + FuncCall(Box), + + AStar(super::AStar), + + AIndices(Box), + + AIndirection(Box), + + AArrayExpr(super::AArrayExpr), + + ResTarget(Box), + + MultiAssignRef(Box), + + TypeCast(Box), + + CollateClause(Box), + + SortBy(Box), + + WindowDef(Box), + + RangeSubselect(Box), + + RangeFunction(super::RangeFunction), + + RangeTableSample(Box), + + RangeTableFunc(Box), + + RangeTableFuncCol(Box), + + TypeName(super::TypeName), + + ColumnDef(Box), + + IndexElem(Box), + + Constraint(Box), + + DefElem(Box), + + RangeTblEntry(Box), + + RangeTblFunction(Box), + + TableSampleClause(Box), + + WithCheckOption(Box), + + SortGroupClause(super::SortGroupClause), + + GroupingSet(super::GroupingSet), + + WindowClause(Box), + + ObjectWithArgs(super::ObjectWithArgs), + + AccessPriv(super::AccessPriv), + + CreateOpClassItem(super::CreateOpClassItem), + + TableLikeClause(super::TableLikeClause), + + FunctionParameter(Box), + + LockingClause(super::LockingClause), + + RowMarkClause(super::RowMarkClause), + + XmlSerialize(Box), + + WithClause(super::WithClause), + + InferClause(Box), + + OnConflictClause(Box), + + CommonTableExpr(Box), + + RoleSpec(super::RoleSpec), + + TriggerTransition(super::TriggerTransition), + + PartitionElem(Box), + + PartitionSpec(super::PartitionSpec), + + PartitionBoundSpec(super::PartitionBoundSpec), + + PartitionRangeDatum(Box), + + PartitionCmd(super::PartitionCmd), + + VacuumRelation(super::VacuumRelation), + + InlineCodeBlock(super::InlineCodeBlock), + + CallContext(super::CallContext), + + Integer(super::Integer), + + Float(super::Float), + + String(super::String2), + + BitString(super::BitString), + + Null(super::Null), + + List(super::List), + + IntList(super::IntList), + + OidList(super::OidList), + } +} +#[derive(Clone, PartialEq)] +pub struct Integer { + /// machine integer + pub ival: i32, +} +#[derive(Clone, PartialEq)] +pub struct Float { + /// string + pub str: String, +} +#[derive(Clone, PartialEq)] +pub struct String2 { + /// string + pub str: String, +} +#[derive(Clone, PartialEq)] +pub struct BitString { + /// string + pub str: String, +} +/// intentionally empty +#[derive(Clone, PartialEq)] +pub struct Null {} +#[derive(Clone, PartialEq)] +pub struct List { + pub items: Vec, +} +#[derive(Clone, PartialEq)] +pub struct OidList { + pub items: Vec, +} +#[derive(Clone, PartialEq)] +pub struct IntList { + pub items: Vec, +} +#[derive(Clone, PartialEq)] +pub struct Alias { + pub aliasname: String, + + pub colnames: Vec, +} +#[derive(Clone, PartialEq)] +pub struct RangeVar { + pub catalogname: String, + + pub schemaname: String, + + pub relname: String, + + pub inh: bool, + + pub relpersistence: String, + + pub alias: ::core::option::Option, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct TableFunc { + pub ns_uris: Vec, + + pub ns_names: Vec, + + pub docexpr: ::core::option::Option>, + + pub rowexpr: ::core::option::Option>, + + pub colnames: Vec, + + pub coltypes: Vec, + + pub coltypmods: Vec, + + pub colcollations: Vec, + + pub colexprs: Vec, + + pub coldefexprs: Vec, + + pub notnulls: Vec, + + pub ordinalitycol: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct Expr {} +#[derive(Clone, PartialEq)] +pub struct Var { + pub xpr: ::core::option::Option>, + + pub varno: u32, + + pub varattno: i32, + + pub vartype: u32, + + pub vartypmod: i32, + + pub varcollid: u32, + + pub varlevelsup: u32, + + pub varnosyn: u32, + + pub varattnosyn: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct Param { + pub xpr: ::core::option::Option>, + + pub paramkind: i32, + + pub paramid: i32, + + pub paramtype: u32, + + pub paramtypmod: i32, + + pub paramcollid: u32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct Aggref { + pub xpr: ::core::option::Option>, + + pub aggfnoid: u32, + + pub aggtype: u32, + + pub aggcollid: u32, + + pub inputcollid: u32, + + pub aggtranstype: u32, + + pub aggargtypes: Vec, + + pub aggdirectargs: Vec, + + pub args: Vec, + + pub aggorder: Vec, + + pub aggdistinct: Vec, + + pub aggfilter: ::core::option::Option>, + + pub aggstar: bool, + + pub aggvariadic: bool, + + pub aggkind: String, + + pub agglevelsup: u32, + + pub aggsplit: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct GroupingFunc { + pub xpr: ::core::option::Option>, + + pub args: Vec, + + pub refs: Vec, + + pub cols: Vec, + + pub agglevelsup: u32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct WindowFunc { + pub xpr: ::core::option::Option>, + + pub winfnoid: u32, + + pub wintype: u32, + + pub wincollid: u32, + + pub inputcollid: u32, + + pub args: Vec, + + pub aggfilter: ::core::option::Option>, + + pub winref: u32, + + pub winstar: bool, + + pub winagg: bool, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SubscriptingRef { + pub xpr: ::core::option::Option>, + + pub refcontainertype: u32, + + pub refelemtype: u32, + + pub reftypmod: i32, + + pub refcollid: u32, + + pub refupperindexpr: Vec, + + pub reflowerindexpr: Vec, + + pub refexpr: ::core::option::Option>, + + pub refassgnexpr: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct FuncExpr { + pub xpr: ::core::option::Option>, + + pub funcid: u32, + + pub funcresulttype: u32, + + pub funcretset: bool, + + pub funcvariadic: bool, + + pub funcformat: i32, + + pub funccollid: u32, + + pub inputcollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct NamedArgExpr { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub name: String, + + pub argnumber: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct OpExpr { + pub xpr: ::core::option::Option>, + + pub opno: u32, + + pub opfuncid: u32, + + pub opresulttype: u32, + + pub opretset: bool, + + pub opcollid: u32, + + pub inputcollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct DistinctExpr { + pub xpr: ::core::option::Option>, + + pub opno: u32, + + pub opfuncid: u32, + + pub opresulttype: u32, + + pub opretset: bool, + + pub opcollid: u32, + + pub inputcollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct NullIfExpr { + pub xpr: ::core::option::Option>, + + pub opno: u32, + + pub opfuncid: u32, + + pub opresulttype: u32, + + pub opretset: bool, + + pub opcollid: u32, + + pub inputcollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ScalarArrayOpExpr { + pub xpr: ::core::option::Option>, + + pub opno: u32, + + pub opfuncid: u32, + + pub use_or: bool, + + pub inputcollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct BoolExpr { + pub xpr: ::core::option::Option>, + + pub boolop: i32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SubLink { + pub xpr: ::core::option::Option>, + + pub sub_link_type: i32, + + pub sub_link_id: i32, + + pub testexpr: ::core::option::Option>, + + pub oper_name: Vec, + + pub subselect: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SubPlan { + pub xpr: ::core::option::Option>, + + pub sub_link_type: i32, + + pub testexpr: ::core::option::Option>, + + pub param_ids: Vec, + + pub plan_id: i32, + + pub plan_name: String, + + pub first_col_type: u32, + + pub first_col_typmod: i32, + + pub first_col_collation: u32, + + pub use_hash_table: bool, + + pub unknown_eq_false: bool, + + pub parallel_safe: bool, + + pub set_param: Vec, + + pub par_param: Vec, + + pub args: Vec, + + pub startup_cost: f64, + + pub per_call_cost: f64, +} +#[derive(Clone, PartialEq)] +pub struct AlternativeSubPlan { + pub xpr: ::core::option::Option>, + + pub subplans: Vec, +} +#[derive(Clone, PartialEq)] +pub struct FieldSelect { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub fieldnum: i32, + + pub resulttype: u32, + + pub resulttypmod: i32, + + pub resultcollid: u32, +} +#[derive(Clone, PartialEq)] +pub struct FieldStore { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub newvals: Vec, + + pub fieldnums: Vec, + + pub resulttype: u32, +} +#[derive(Clone, PartialEq)] +pub struct RelabelType { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub resulttype: u32, + + pub resulttypmod: i32, + + pub resultcollid: u32, + + pub relabelformat: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CoerceViaIo { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub resulttype: u32, + + pub resultcollid: u32, + + pub coerceformat: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ArrayCoerceExpr { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub elemexpr: ::core::option::Option>, + + pub resulttype: u32, + + pub resulttypmod: i32, + + pub resultcollid: u32, + + pub coerceformat: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ConvertRowtypeExpr { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub resulttype: u32, + + pub convertformat: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CollateExpr { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub coll_oid: u32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CaseExpr { + pub xpr: ::core::option::Option>, + + pub casetype: u32, + + pub casecollid: u32, + + pub arg: ::core::option::Option>, + + pub args: Vec, + + pub defresult: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CaseWhen { + pub xpr: ::core::option::Option>, + + pub expr: ::core::option::Option>, + + pub result: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CaseTestExpr { + pub xpr: ::core::option::Option>, + + pub type_id: u32, + + pub type_mod: i32, + + pub collation: u32, +} +#[derive(Clone, PartialEq)] +pub struct ArrayExpr { + pub xpr: ::core::option::Option>, + + pub array_typeid: u32, + + pub array_collid: u32, + + pub element_typeid: u32, + + pub elements: Vec, + + pub multidims: bool, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RowExpr { + pub xpr: ::core::option::Option>, + + pub args: Vec, + + pub row_typeid: u32, + + pub row_format: i32, + + pub colnames: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RowCompareExpr { + pub xpr: ::core::option::Option>, + + pub rctype: i32, + + pub opnos: Vec, + + pub opfamilies: Vec, + + pub inputcollids: Vec, + + pub largs: Vec, + + pub rargs: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CoalesceExpr { + pub xpr: ::core::option::Option>, + + pub coalescetype: u32, + + pub coalescecollid: u32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct MinMaxExpr { + pub xpr: ::core::option::Option>, + + pub minmaxtype: u32, + + pub minmaxcollid: u32, + + pub inputcollid: u32, + + pub op: i32, + + pub args: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SqlValueFunction { + pub xpr: ::core::option::Option>, + + pub op: i32, + + pub r#type: u32, + + pub typmod: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct XmlExpr { + pub xpr: ::core::option::Option>, + + pub op: i32, + + pub name: String, + + pub named_args: Vec, + + pub arg_names: Vec, + + pub args: Vec, + + pub xmloption: i32, + + pub r#type: u32, + + pub typmod: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct NullTest { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub nulltesttype: i32, + + pub argisrow: bool, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct BooleanTest { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub booltesttype: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CoerceToDomain { + pub xpr: ::core::option::Option>, + + pub arg: ::core::option::Option>, + + pub resulttype: u32, + + pub resulttypmod: i32, + + pub resultcollid: u32, + + pub coercionformat: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CoerceToDomainValue { + pub xpr: ::core::option::Option>, + + pub type_id: u32, + + pub type_mod: i32, + + pub collation: u32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SetToDefault { + pub xpr: ::core::option::Option>, + + pub type_id: u32, + + pub type_mod: i32, + + pub collation: u32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CurrentOfExpr { + pub xpr: ::core::option::Option>, + + pub cvarno: u32, + + pub cursor_name: String, + + pub cursor_param: i32, +} +#[derive(Clone, PartialEq)] +pub struct NextValueExpr { + pub xpr: ::core::option::Option>, + + pub seqid: u32, + + pub type_id: u32, +} +#[derive(Clone, PartialEq)] +pub struct InferenceElem { + pub xpr: ::core::option::Option>, + + pub expr: ::core::option::Option>, + + pub infercollid: u32, + + pub inferopclass: u32, +} +#[derive(Clone, PartialEq)] +pub struct TargetEntry { + pub xpr: ::core::option::Option>, + + pub expr: ::core::option::Option>, + + pub resno: i32, + + pub resname: String, + + pub ressortgroupref: u32, + + pub resorigtbl: u32, + + pub resorigcol: i32, + + pub resjunk: bool, +} +#[derive(Clone, PartialEq)] +pub struct RangeTblRef { + pub rtindex: i32, +} +#[derive(Clone, PartialEq)] +pub struct JoinExpr { + pub jointype: i32, + + pub is_natural: bool, + + pub larg: ::core::option::Option>, + + pub rarg: ::core::option::Option>, + + pub using_clause: Vec, + + pub quals: ::core::option::Option>, + + pub alias: ::core::option::Option, + + pub rtindex: i32, +} +#[derive(Clone, PartialEq)] +pub struct FromExpr { + pub fromlist: Vec, + + pub quals: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct OnConflictExpr { + pub action: i32, + + pub arbiter_elems: Vec, + + pub arbiter_where: ::core::option::Option>, + + pub constraint: u32, + + pub on_conflict_set: Vec, + + pub on_conflict_where: ::core::option::Option>, + + pub excl_rel_index: i32, + + pub excl_rel_tlist: Vec, +} +#[derive(Clone, PartialEq)] +pub struct IntoClause { + pub rel: ::core::option::Option, + + pub col_names: Vec, + + pub access_method: String, + + pub options: Vec, + + pub on_commit: i32, + + pub table_space_name: String, + + pub view_query: ::core::option::Option>, + + pub skip_data: bool, +} +#[derive(Clone, PartialEq)] +pub struct RawStmt { + pub stmt: ::core::option::Option>, + + pub stmt_location: i32, + + pub stmt_len: i32, +} +#[derive(Clone, PartialEq)] +pub struct Query { + pub command_type: i32, + + pub query_source: i32, + + pub can_set_tag: bool, + + pub utility_stmt: ::core::option::Option>, + + pub result_relation: i32, + + pub has_aggs: bool, + + pub has_window_funcs: bool, + + pub has_target_srfs: bool, + + pub has_sub_links: bool, + + pub has_distinct_on: bool, + + pub has_recursive: bool, + + pub has_modifying_cte: bool, + + pub has_for_update: bool, + + pub has_row_security: bool, + + pub cte_list: Vec, + + pub rtable: Vec, + + pub jointree: ::core::option::Option>, + + pub target_list: Vec, + + pub r#override: i32, + + pub on_conflict: ::core::option::Option>, + + pub returning_list: Vec, + + pub group_clause: Vec, + + pub grouping_sets: Vec, + + pub having_qual: ::core::option::Option>, + + pub window_clause: Vec, + + pub distinct_clause: Vec, + + pub sort_clause: Vec, + + pub limit_offset: ::core::option::Option>, + + pub limit_count: ::core::option::Option>, + + pub limit_option: i32, + + pub row_marks: Vec, + + pub set_operations: ::core::option::Option>, + + pub constraint_deps: Vec, + + pub with_check_options: Vec, + + pub stmt_location: i32, + + pub stmt_len: i32, +} +#[derive(Clone, PartialEq)] +pub struct InsertStmt { + pub relation: ::core::option::Option, + + pub cols: Vec, + + pub select_stmt: ::core::option::Option>, + + pub on_conflict_clause: ::core::option::Option>, + + pub returning_list: Vec, + + pub with_clause: ::core::option::Option, + + pub r#override: i32, +} +#[derive(Clone, PartialEq)] +pub struct DeleteStmt { + pub relation: ::core::option::Option, + + pub using_clause: Vec, + + pub where_clause: ::core::option::Option>, + + pub returning_list: Vec, + + pub with_clause: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct UpdateStmt { + pub relation: ::core::option::Option, + + pub target_list: Vec, + + pub where_clause: ::core::option::Option>, + + pub from_clause: Vec, + + pub returning_list: Vec, + + pub with_clause: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct SelectStmt { + pub distinct_clause: Vec, + + pub into_clause: ::core::option::Option>, + + pub target_list: Vec, + + pub from_clause: Vec, + + pub where_clause: ::core::option::Option>, + + pub group_clause: Vec, + + pub having_clause: ::core::option::Option>, + + pub window_clause: Vec, + + pub values_lists: Vec, + + pub sort_clause: Vec, + + pub limit_offset: ::core::option::Option>, + + pub limit_count: ::core::option::Option>, + + pub limit_option: i32, + + pub locking_clause: Vec, + + pub with_clause: ::core::option::Option, + + pub op: i32, + + pub all: bool, + + pub larg: ::core::option::Option>, + + pub rarg: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct AlterTableStmt { + pub relation: ::core::option::Option, + + pub cmds: Vec, + + pub relkind: i32, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterTableCmd { + pub subtype: i32, + + pub name: String, + + pub num: i32, + + pub newowner: ::core::option::Option, + + pub def: ::core::option::Option>, + + pub behavior: i32, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterDomainStmt { + pub subtype: String, + + pub type_name: Vec, + + pub name: String, + + pub def: ::core::option::Option>, + + pub behavior: i32, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct SetOperationStmt { + pub op: i32, + + pub all: bool, + + pub larg: ::core::option::Option>, + + pub rarg: ::core::option::Option>, + + pub col_types: Vec, + + pub col_typmods: Vec, + + pub col_collations: Vec, + + pub group_clauses: Vec, +} +#[derive(Clone, PartialEq)] +pub struct GrantStmt { + pub is_grant: bool, + + pub targtype: i32, + + pub objtype: i32, + + pub objects: Vec, + + pub privileges: Vec, + + pub grantees: Vec, + + pub grant_option: bool, + + pub behavior: i32, +} +#[derive(Clone, PartialEq)] +pub struct GrantRoleStmt { + pub granted_roles: Vec, + + pub grantee_roles: Vec, + + pub is_grant: bool, + + pub admin_opt: bool, + + pub grantor: ::core::option::Option, + + pub behavior: i32, +} +#[derive(Clone, PartialEq)] +pub struct AlterDefaultPrivilegesStmt { + pub options: Vec, + + pub action: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct ClosePortalStmt { + pub portalname: String, +} +#[derive(Clone, PartialEq)] +pub struct ClusterStmt { + pub relation: ::core::option::Option, + + pub indexname: String, + + pub options: i32, +} +#[derive(Clone, PartialEq)] +pub struct CopyStmt { + pub relation: ::core::option::Option, + + pub query: ::core::option::Option>, + + pub attlist: Vec, + + pub is_from: bool, + + pub is_program: bool, + + pub filename: String, + + pub options: Vec, + + pub where_clause: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct CreateStmt { + pub relation: ::core::option::Option, + + pub table_elts: Vec, + + pub inh_relations: Vec, + + pub partbound: ::core::option::Option, + + pub partspec: ::core::option::Option, + + pub of_typename: ::core::option::Option, + + pub constraints: Vec, + + pub options: Vec, + + pub oncommit: i32, + + pub tablespacename: String, + + pub access_method: String, + + pub if_not_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct DefineStmt { + pub kind: i32, + + pub oldstyle: bool, + + pub defnames: Vec, + + pub args: Vec, + + pub definition: Vec, + + pub if_not_exists: bool, + + pub replace: bool, +} +#[derive(Clone, PartialEq)] +pub struct DropStmt { + pub objects: Vec, + + pub remove_type: i32, + + pub behavior: i32, + + pub missing_ok: bool, + + pub concurrent: bool, +} +#[derive(Clone, PartialEq)] +pub struct TruncateStmt { + pub relations: Vec, + + pub restart_seqs: bool, + + pub behavior: i32, +} +#[derive(Clone, PartialEq)] +pub struct CommentStmt { + pub objtype: i32, + + pub object: ::core::option::Option>, + + pub comment: String, +} +#[derive(Clone, PartialEq)] +pub struct FetchStmt { + pub direction: i32, + + pub how_many: i64, + + pub portalname: String, + + pub ismove: bool, +} +#[derive(Clone, PartialEq)] +pub struct IndexStmt { + pub idxname: String, + + pub relation: ::core::option::Option, + + pub access_method: String, + + pub table_space: String, + + pub index_params: Vec, + + pub index_including_params: Vec, + + pub options: Vec, + + pub where_clause: ::core::option::Option>, + + pub exclude_op_names: Vec, + + pub idxcomment: String, + + pub index_oid: u32, + + pub old_node: u32, + + pub old_create_subid: u32, + + pub old_first_relfilenode_subid: u32, + + pub unique: bool, + + pub primary: bool, + + pub isconstraint: bool, + + pub deferrable: bool, + + pub initdeferred: bool, + + pub transformed: bool, + + pub concurrent: bool, + + pub if_not_exists: bool, + + pub reset_default_tblspc: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateFunctionStmt { + pub is_procedure: bool, + + pub replace: bool, + + pub funcname: Vec, + + pub parameters: Vec, + + pub return_type: ::core::option::Option, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterFunctionStmt { + pub objtype: i32, + + pub func: ::core::option::Option, + + pub actions: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DoStmt { + pub args: Vec, +} +#[derive(Clone, PartialEq)] +pub struct RenameStmt { + pub rename_type: i32, + + pub relation_type: i32, + + pub relation: ::core::option::Option, + + pub object: ::core::option::Option>, + + pub subname: String, + + pub newname: String, + + pub behavior: i32, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct RuleStmt { + pub relation: ::core::option::Option, + + pub rulename: String, + + pub where_clause: ::core::option::Option>, + + pub event: i32, + + pub instead: bool, + + pub actions: Vec, + + pub replace: bool, +} +#[derive(Clone, PartialEq)] +pub struct NotifyStmt { + pub conditionname: String, + + pub payload: String, +} +#[derive(Clone, PartialEq)] +pub struct ListenStmt { + pub conditionname: String, +} +#[derive(Clone, PartialEq)] +pub struct UnlistenStmt { + pub conditionname: String, +} +#[derive(Clone, PartialEq)] +pub struct TransactionStmt { + pub kind: i32, + + pub options: Vec, + + pub savepoint_name: String, + + pub gid: String, + + pub chain: bool, +} +#[derive(Clone, PartialEq)] +pub struct ViewStmt { + pub view: ::core::option::Option, + + pub aliases: Vec, + + pub query: ::core::option::Option>, + + pub replace: bool, + + pub options: Vec, + + pub with_check_option: i32, +} +#[derive(Clone, PartialEq)] +pub struct LoadStmt { + pub filename: String, +} +#[derive(Clone, PartialEq)] +pub struct CreateDomainStmt { + pub domainname: Vec, + + pub type_name: ::core::option::Option, + + pub coll_clause: ::core::option::Option>, + + pub constraints: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreatedbStmt { + pub dbname: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DropdbStmt { + pub dbname: String, + + pub missing_ok: bool, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct VacuumStmt { + pub options: Vec, + + pub rels: Vec, + + pub is_vacuumcmd: bool, +} +#[derive(Clone, PartialEq)] +pub struct ExplainStmt { + pub query: ::core::option::Option>, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateTableAsStmt { + pub query: ::core::option::Option>, + + pub into: ::core::option::Option>, + + pub relkind: i32, + + pub is_select_into: bool, + + pub if_not_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateSeqStmt { + pub sequence: ::core::option::Option, + + pub options: Vec, + + pub owner_id: u32, + + pub for_identity: bool, + + pub if_not_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterSeqStmt { + pub sequence: ::core::option::Option, + + pub options: Vec, + + pub for_identity: bool, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct VariableSetStmt { + pub kind: i32, + + pub name: String, + + pub args: Vec, + + pub is_local: bool, +} +#[derive(Clone, PartialEq)] +pub struct VariableShowStmt { + pub name: String, +} +#[derive(Clone, PartialEq)] +pub struct DiscardStmt { + pub target: i32, +} +#[derive(Clone, PartialEq)] +pub struct CreateTrigStmt { + pub trigname: String, + + pub relation: ::core::option::Option, + + pub funcname: Vec, + + pub args: Vec, + + pub row: bool, + + pub timing: i32, + + pub events: i32, + + pub columns: Vec, + + pub when_clause: ::core::option::Option>, + + pub isconstraint: bool, + + pub transition_rels: Vec, + + pub deferrable: bool, + + pub initdeferred: bool, + + pub constrrel: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct CreatePLangStmt { + pub replace: bool, + + pub plname: String, + + pub plhandler: Vec, + + pub plinline: Vec, + + pub plvalidator: Vec, + + pub pltrusted: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateRoleStmt { + pub stmt_type: i32, + + pub role: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterRoleStmt { + pub role: ::core::option::Option, + + pub options: Vec, + + pub action: i32, +} +#[derive(Clone, PartialEq)] +pub struct DropRoleStmt { + pub roles: Vec, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct LockStmt { + pub relations: Vec, + + pub mode: i32, + + pub nowait: bool, +} +#[derive(Clone, PartialEq)] +pub struct ConstraintsSetStmt { + pub constraints: Vec, + + pub deferred: bool, +} +#[derive(Clone, PartialEq)] +pub struct ReindexStmt { + pub kind: i32, + + pub relation: ::core::option::Option, + + pub name: String, + + pub options: i32, + + pub concurrent: bool, +} +#[derive(Clone, PartialEq)] +pub struct CheckPointStmt {} +#[derive(Clone, PartialEq)] +pub struct CreateSchemaStmt { + pub schemaname: String, + + pub authrole: ::core::option::Option, + + pub schema_elts: Vec, + + pub if_not_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterDatabaseStmt { + pub dbname: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterDatabaseSetStmt { + pub dbname: String, + + pub setstmt: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct AlterRoleSetStmt { + pub role: ::core::option::Option, + + pub database: String, + + pub setstmt: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct CreateConversionStmt { + pub conversion_name: Vec, + + pub for_encoding_name: String, + + pub to_encoding_name: String, + + pub func_name: Vec, + + pub def: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateCastStmt { + pub sourcetype: ::core::option::Option, + + pub targettype: ::core::option::Option, + + pub func: ::core::option::Option, + + pub context: i32, + + pub inout: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateOpClassStmt { + pub opclassname: Vec, + + pub opfamilyname: Vec, + + pub amname: String, + + pub datatype: ::core::option::Option, + + pub items: Vec, + + pub is_default: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateOpFamilyStmt { + pub opfamilyname: Vec, + + pub amname: String, +} +#[derive(Clone, PartialEq)] +pub struct AlterOpFamilyStmt { + pub opfamilyname: Vec, + + pub amname: String, + + pub is_drop: bool, + + pub items: Vec, +} +#[derive(Clone, PartialEq)] +pub struct PrepareStmt { + pub name: String, + + pub argtypes: Vec, + + pub query: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct ExecuteStmt { + pub name: String, + + pub params: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DeallocateStmt { + pub name: String, +} +#[derive(Clone, PartialEq)] +pub struct DeclareCursorStmt { + pub portalname: String, + + pub options: i32, + + pub query: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct CreateTableSpaceStmt { + pub tablespacename: String, + + pub owner: ::core::option::Option, + + pub location: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DropTableSpaceStmt { + pub tablespacename: String, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterObjectDependsStmt { + pub object_type: i32, + + pub relation: ::core::option::Option, + + pub object: ::core::option::Option>, + + pub extname: ::core::option::Option>, + + pub remove: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterObjectSchemaStmt { + pub object_type: i32, + + pub relation: ::core::option::Option, + + pub object: ::core::option::Option>, + + pub newschema: String, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterOwnerStmt { + pub object_type: i32, + + pub relation: ::core::option::Option, + + pub object: ::core::option::Option>, + + pub newowner: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct AlterOperatorStmt { + pub opername: ::core::option::Option, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterTypeStmt { + pub type_name: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DropOwnedStmt { + pub roles: Vec, + + pub behavior: i32, +} +#[derive(Clone, PartialEq)] +pub struct ReassignOwnedStmt { + pub roles: Vec, + + pub newrole: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct CompositeTypeStmt { + pub typevar: ::core::option::Option, + + pub coldeflist: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateEnumStmt { + pub type_name: Vec, + + pub vals: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateRangeStmt { + pub type_name: Vec, + + pub params: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterEnumStmt { + pub type_name: Vec, + + pub old_val: String, + + pub new_val: String, + + pub new_val_neighbor: String, + + pub new_val_is_after: bool, + + pub skip_if_new_val_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterTsDictionaryStmt { + pub dictname: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterTsConfigurationStmt { + pub kind: i32, + + pub cfgname: Vec, + + pub tokentype: Vec, + + pub dicts: Vec, + + pub r#override: bool, + + pub replace: bool, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateFdwStmt { + pub fdwname: String, + + pub func_options: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterFdwStmt { + pub fdwname: String, + + pub func_options: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateForeignServerStmt { + pub servername: String, + + pub servertype: String, + + pub version: String, + + pub fdwname: String, + + pub if_not_exists: bool, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterForeignServerStmt { + pub servername: String, + + pub version: String, + + pub options: Vec, + + pub has_version: bool, +} +#[derive(Clone, PartialEq)] +pub struct CreateUserMappingStmt { + pub user: ::core::option::Option, + + pub servername: String, + + pub if_not_exists: bool, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterUserMappingStmt { + pub user: ::core::option::Option, + + pub servername: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DropUserMappingStmt { + pub user: ::core::option::Option, + + pub servername: String, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterTableSpaceOptionsStmt { + pub tablespacename: String, + + pub options: Vec, + + pub is_reset: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterTableMoveAllStmt { + pub orig_tablespacename: String, + + pub objtype: i32, + + pub roles: Vec, + + pub new_tablespacename: String, + + pub nowait: bool, +} +#[derive(Clone, PartialEq)] +pub struct SecLabelStmt { + pub objtype: i32, + + pub object: ::core::option::Option>, + + pub provider: String, + + pub label: String, +} +#[derive(Clone, PartialEq)] +pub struct CreateForeignTableStmt { + pub base_stmt: ::core::option::Option, + + pub servername: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct ImportForeignSchemaStmt { + pub server_name: String, + + pub remote_schema: String, + + pub local_schema: String, + + pub list_type: i32, + + pub table_list: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateExtensionStmt { + pub extname: String, + + pub if_not_exists: bool, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterExtensionStmt { + pub extname: String, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterExtensionContentsStmt { + pub extname: String, + + pub action: i32, + + pub objtype: i32, + + pub object: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct CreateEventTrigStmt { + pub trigname: String, + + pub eventname: String, + + pub whenclause: Vec, + + pub funcname: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterEventTrigStmt { + pub trigname: String, + + pub tgenabled: String, +} +#[derive(Clone, PartialEq)] +pub struct RefreshMatViewStmt { + pub concurrent: bool, + + pub skip_data: bool, + + pub relation: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct ReplicaIdentityStmt { + pub identity_type: String, + + pub name: String, +} +#[derive(Clone, PartialEq)] +pub struct AlterSystemStmt { + pub setstmt: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct CreatePolicyStmt { + pub policy_name: String, + + pub table: ::core::option::Option, + + pub cmd_name: String, + + pub permissive: bool, + + pub roles: Vec, + + pub qual: ::core::option::Option>, + + pub with_check: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct AlterPolicyStmt { + pub policy_name: String, + + pub table: ::core::option::Option, + + pub roles: Vec, + + pub qual: ::core::option::Option>, + + pub with_check: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct CreateTransformStmt { + pub replace: bool, + + pub type_name: ::core::option::Option, + + pub lang: String, + + pub fromsql: ::core::option::Option, + + pub tosql: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct CreateAmStmt { + pub amname: String, + + pub handler_name: Vec, + + pub amtype: String, +} +#[derive(Clone, PartialEq)] +pub struct CreatePublicationStmt { + pub pubname: String, + + pub options: Vec, + + pub tables: Vec, + + pub for_all_tables: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterPublicationStmt { + pub pubname: String, + + pub options: Vec, + + pub tables: Vec, + + pub for_all_tables: bool, + + pub table_action: i32, +} +#[derive(Clone, PartialEq)] +pub struct CreateSubscriptionStmt { + pub subname: String, + + pub conninfo: String, + + pub publication: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AlterSubscriptionStmt { + pub kind: i32, + + pub subname: String, + + pub conninfo: String, + + pub publication: Vec, + + pub options: Vec, +} +#[derive(Clone, PartialEq)] +pub struct DropSubscriptionStmt { + pub subname: String, + + pub missing_ok: bool, + + pub behavior: i32, +} +#[derive(Clone, PartialEq)] +pub struct CreateStatsStmt { + pub defnames: Vec, + + pub stat_types: Vec, + + pub exprs: Vec, + + pub relations: Vec, + + pub stxcomment: String, + + pub if_not_exists: bool, +} +#[derive(Clone, PartialEq)] +pub struct AlterCollationStmt { + pub collname: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CallStmt { + pub funccall: ::core::option::Option>, + + pub funcexpr: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct AlterStatsStmt { + pub defnames: Vec, + + pub stxstattarget: i32, + + pub missing_ok: bool, +} +#[derive(Clone, PartialEq)] +pub struct AExpr { + pub kind: i32, + + pub name: Vec, + + pub lexpr: ::core::option::Option>, + + pub rexpr: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ColumnRef { + pub fields: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ParamRef { + pub number: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct AConst { + pub val: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct FuncCall { + pub funcname: Vec, + + pub args: Vec, + + pub agg_order: Vec, + + pub agg_filter: ::core::option::Option>, + + pub agg_within_group: bool, + + pub agg_star: bool, + + pub agg_distinct: bool, + + pub func_variadic: bool, + + pub over: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct AStar {} +#[derive(Clone, PartialEq)] +pub struct AIndices { + pub is_slice: bool, + + pub lidx: ::core::option::Option>, + + pub uidx: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct AIndirection { + pub arg: ::core::option::Option>, + + pub indirection: Vec, +} +#[derive(Clone, PartialEq)] +pub struct AArrayExpr { + pub elements: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ResTarget { + pub name: String, + + pub indirection: Vec, + + pub val: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct MultiAssignRef { + pub source: ::core::option::Option>, + + pub colno: i32, + + pub ncolumns: i32, +} +#[derive(Clone, PartialEq)] +pub struct TypeCast { + pub arg: ::core::option::Option>, + + pub type_name: ::core::option::Option, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CollateClause { + pub arg: ::core::option::Option>, + + pub collname: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct SortBy { + pub node: ::core::option::Option>, + + pub sortby_dir: i32, + + pub sortby_nulls: i32, + + pub use_op: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct WindowDef { + pub name: String, + + pub refname: String, + + pub partition_clause: Vec, + + pub order_clause: Vec, + + pub frame_options: i32, + + pub start_offset: ::core::option::Option>, + + pub end_offset: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RangeSubselect { + pub lateral: bool, + + pub subquery: ::core::option::Option>, + + pub alias: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct RangeFunction { + pub lateral: bool, + + pub ordinality: bool, + + pub is_rowsfrom: bool, + + pub functions: Vec, + + pub alias: ::core::option::Option, + + pub coldeflist: Vec, +} +#[derive(Clone, PartialEq)] +pub struct RangeTableSample { + pub relation: ::core::option::Option>, + + pub method: Vec, + + pub args: Vec, + + pub repeatable: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RangeTableFunc { + pub lateral: bool, + + pub docexpr: ::core::option::Option>, + + pub rowexpr: ::core::option::Option>, + + pub namespaces: Vec, + + pub columns: Vec, + + pub alias: ::core::option::Option, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RangeTableFuncCol { + pub colname: String, + + pub type_name: ::core::option::Option, + + pub for_ordinality: bool, + + pub is_not_null: bool, + + pub colexpr: ::core::option::Option>, + + pub coldefexpr: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct TypeName { + pub names: Vec, + + pub type_oid: u32, + + pub setof: bool, + + pub pct_type: bool, + + pub typmods: Vec, + + pub typemod: i32, + + pub array_bounds: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct ColumnDef { + pub colname: String, + + pub type_name: ::core::option::Option, + + pub inhcount: i32, + + pub is_local: bool, + + pub is_not_null: bool, + + pub is_from_type: bool, + + pub storage: String, + + pub raw_default: ::core::option::Option>, + + pub cooked_default: ::core::option::Option>, + + pub identity: String, + + pub identity_sequence: ::core::option::Option, + + pub generated: String, + + pub coll_clause: ::core::option::Option>, + + pub coll_oid: u32, + + pub constraints: Vec, + + pub fdwoptions: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct IndexElem { + pub name: String, + + pub expr: ::core::option::Option>, + + pub indexcolname: String, + + pub collation: Vec, + + pub opclass: Vec, + + pub opclassopts: Vec, + + pub ordering: i32, + + pub nulls_ordering: i32, +} +#[derive(Clone, PartialEq)] +pub struct Constraint { + pub contype: i32, + + pub conname: String, + + pub deferrable: bool, + + pub initdeferred: bool, + + pub location: i32, + + pub is_no_inherit: bool, + + pub raw_expr: ::core::option::Option>, + + pub cooked_expr: String, + + pub generated_when: String, + + pub keys: Vec, + + pub including: Vec, + + pub exclusions: Vec, + + pub options: Vec, + + pub indexname: String, + + pub indexspace: String, + + pub reset_default_tblspc: bool, + + pub access_method: String, + + pub where_clause: ::core::option::Option>, + + pub pktable: ::core::option::Option, + + pub fk_attrs: Vec, + + pub pk_attrs: Vec, + + pub fk_matchtype: String, + + pub fk_upd_action: String, + + pub fk_del_action: String, + + pub old_conpfeqop: Vec, + + pub old_pktable_oid: u32, + + pub skip_validation: bool, + + pub initially_valid: bool, +} +#[derive(Clone, PartialEq)] +pub struct DefElem { + pub defnamespace: String, + + pub defname: String, + + pub arg: ::core::option::Option>, + + pub defaction: i32, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct RangeTblEntry { + pub rtekind: i32, + + pub relid: u32, + + pub relkind: String, + + pub rellockmode: i32, + + pub tablesample: ::core::option::Option>, + + pub subquery: ::core::option::Option>, + + pub security_barrier: bool, + + pub jointype: i32, + + pub joinmergedcols: i32, + + pub joinaliasvars: Vec, + + pub joinleftcols: Vec, + + pub joinrightcols: Vec, + + pub functions: Vec, + + pub funcordinality: bool, + + pub tablefunc: ::core::option::Option>, + + pub values_lists: Vec, + + pub ctename: String, + + pub ctelevelsup: u32, + + pub self_reference: bool, + + pub coltypes: Vec, + + pub coltypmods: Vec, + + pub colcollations: Vec, + + pub enrname: String, + + pub enrtuples: f64, + + pub alias: ::core::option::Option, + + pub eref: ::core::option::Option, + + pub lateral: bool, + + pub inh: bool, + + pub in_from_cl: bool, + + pub required_perms: u32, + + pub check_as_user: u32, + + pub selected_cols: Vec, + + pub inserted_cols: Vec, + + pub updated_cols: Vec, + + pub extra_updated_cols: Vec, + + pub security_quals: Vec, +} +#[derive(Clone, PartialEq)] +pub struct RangeTblFunction { + pub funcexpr: ::core::option::Option>, + + pub funccolcount: i32, + + pub funccolnames: Vec, + + pub funccoltypes: Vec, + + pub funccoltypmods: Vec, + + pub funccolcollations: Vec, + + pub funcparams: Vec, +} +#[derive(Clone, PartialEq)] +pub struct TableSampleClause { + pub tsmhandler: u32, + + pub args: Vec, + + pub repeatable: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct WithCheckOption { + pub kind: i32, + + pub relname: String, + + pub polname: String, + + pub qual: ::core::option::Option>, + + pub cascaded: bool, +} +#[derive(Clone, PartialEq)] +pub struct SortGroupClause { + pub tle_sort_group_ref: u32, + + pub eqop: u32, + + pub sortop: u32, + + pub nulls_first: bool, + + pub hashable: bool, +} +#[derive(Clone, PartialEq)] +pub struct GroupingSet { + pub kind: i32, + + pub content: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct WindowClause { + pub name: String, + + pub refname: String, + + pub partition_clause: Vec, + + pub order_clause: Vec, + + pub frame_options: i32, + + pub start_offset: ::core::option::Option>, + + pub end_offset: ::core::option::Option>, + + pub start_in_range_func: u32, + + pub end_in_range_func: u32, + + pub in_range_coll: u32, + + pub in_range_asc: bool, + + pub in_range_nulls_first: bool, + + pub winref: u32, + + pub copied_order: bool, +} +#[derive(Clone, PartialEq)] +pub struct ObjectWithArgs { + pub objname: Vec, + + pub objargs: Vec, + + pub args_unspecified: bool, +} +#[derive(Clone, PartialEq)] +pub struct AccessPriv { + pub priv_name: String, + + pub cols: Vec, +} +#[derive(Clone, PartialEq)] +pub struct CreateOpClassItem { + pub itemtype: i32, + + pub name: ::core::option::Option, + + pub number: i32, + + pub order_family: Vec, + + pub class_args: Vec, + + pub storedtype: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct TableLikeClause { + pub relation: ::core::option::Option, + + pub options: u32, + + pub relation_oid: u32, +} +#[derive(Clone, PartialEq)] +pub struct FunctionParameter { + pub name: String, + + pub arg_type: ::core::option::Option, + + pub mode: i32, + + pub defexpr: ::core::option::Option>, +} +#[derive(Clone, PartialEq)] +pub struct LockingClause { + pub locked_rels: Vec, + + pub strength: i32, + + pub wait_policy: i32, +} +#[derive(Clone, PartialEq)] +pub struct RowMarkClause { + pub rti: u32, + + pub strength: i32, + + pub wait_policy: i32, + + pub pushed_down: bool, +} +#[derive(Clone, PartialEq)] +pub struct XmlSerialize { + pub xmloption: i32, + + pub expr: ::core::option::Option>, + + pub type_name: ::core::option::Option, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct WithClause { + pub ctes: Vec, + + pub recursive: bool, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct InferClause { + pub index_elems: Vec, + + pub where_clause: ::core::option::Option>, + + pub conname: String, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct OnConflictClause { + pub action: i32, + + pub infer: ::core::option::Option>, + + pub target_list: Vec, + + pub where_clause: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct CommonTableExpr { + pub ctename: String, + + pub aliascolnames: Vec, + + pub ctematerialized: i32, + + pub ctequery: ::core::option::Option>, + + pub location: i32, + + pub cterecursive: bool, + + pub cterefcount: i32, + + pub ctecolnames: Vec, + + pub ctecoltypes: Vec, + + pub ctecoltypmods: Vec, + + pub ctecolcollations: Vec, +} +#[derive(Clone, PartialEq)] +pub struct RoleSpec { + pub roletype: i32, + + pub rolename: String, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct TriggerTransition { + pub name: String, + + pub is_new: bool, + + pub is_table: bool, +} +#[derive(Clone, PartialEq)] +pub struct PartitionElem { + pub name: String, + + pub expr: ::core::option::Option>, + + pub collation: Vec, + + pub opclass: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct PartitionSpec { + pub strategy: String, + + pub part_params: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct PartitionBoundSpec { + pub strategy: String, + + pub is_default: bool, + + pub modulus: i32, + + pub remainder: i32, + + pub listdatums: Vec, + + pub lowerdatums: Vec, + + pub upperdatums: Vec, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct PartitionRangeDatum { + pub kind: i32, + + pub value: ::core::option::Option>, + + pub location: i32, +} +#[derive(Clone, PartialEq)] +pub struct PartitionCmd { + pub name: ::core::option::Option, + + pub bound: ::core::option::Option, +} +#[derive(Clone, PartialEq)] +pub struct VacuumRelation { + pub relation: ::core::option::Option, + + pub oid: u32, + + pub va_cols: Vec, +} +#[derive(Clone, PartialEq)] +pub struct InlineCodeBlock { + pub source_text: String, + + pub lang_oid: u32, + + pub lang_is_trusted: bool, + + pub atomic: bool, +} +#[derive(Clone, PartialEq)] +pub struct CallContext { + pub atomic: bool, +} +#[derive(Clone, PartialEq)] +pub struct ScanToken { + pub start: i32, + + pub end: i32, + + pub token: i32, + + pub keyword_kind: i32, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum OverridingKind { + Undefined = 0, + OverridingNotSet = 1, + OverridingUserValue = 2, + OverridingSystemValue = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum QuerySource { + Undefined = 0, + QsrcOriginal = 1, + QsrcParser = 2, + QsrcInsteadRule = 3, + QsrcQualInsteadRule = 4, + QsrcNonInsteadRule = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SortByDir { + Undefined = 0, + SortbyDefault = 1, + SortbyAsc = 2, + SortbyDesc = 3, + SortbyUsing = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SortByNulls { + Undefined = 0, + SortbyNullsDefault = 1, + SortbyNullsFirst = 2, + SortbyNullsLast = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AExprKind { + Undefined = 0, + AexprOp = 1, + AexprOpAny = 2, + AexprOpAll = 3, + AexprDistinct = 4, + AexprNotDistinct = 5, + AexprNullif = 6, + AexprOf = 7, + AexprIn = 8, + AexprLike = 9, + AexprIlike = 10, + AexprSimilar = 11, + AexprBetween = 12, + AexprNotBetween = 13, + AexprBetweenSym = 14, + AexprNotBetweenSym = 15, + AexprParen = 16, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum RoleSpecType { + Undefined = 0, + RolespecCstring = 1, + RolespecCurrentUser = 2, + RolespecSessionUser = 3, + RolespecPublic = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum TableLikeOption { + Undefined = 0, + CreateTableLikeComments = 1, + CreateTableLikeConstraints = 2, + CreateTableLikeDefaults = 3, + CreateTableLikeGenerated = 4, + CreateTableLikeIdentity = 5, + CreateTableLikeIndexes = 6, + CreateTableLikeStatistics = 7, + CreateTableLikeStorage = 8, + CreateTableLikeAll = 9, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum DefElemAction { + Undefined = 0, + DefelemUnspec = 1, + DefelemSet = 2, + DefelemAdd = 3, + DefelemDrop = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum PartitionRangeDatumKind { + Undefined = 0, + PartitionRangeDatumMinvalue = 1, + PartitionRangeDatumValue = 2, + PartitionRangeDatumMaxvalue = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum RteKind { + RtekindUndefined = 0, + RteRelation = 1, + RteSubquery = 2, + RteJoin = 3, + RteFunction = 4, + RteTablefunc = 5, + RteValues = 6, + RteCte = 7, + RteNamedtuplestore = 8, + RteResult = 9, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum WcoKind { + WcokindUndefined = 0, + WcoViewCheck = 1, + WcoRlsInsertCheck = 2, + WcoRlsUpdateCheck = 3, + WcoRlsConflictCheck = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum GroupingSetKind { + Undefined = 0, + GroupingSetEmpty = 1, + GroupingSetSimple = 2, + GroupingSetRollup = 3, + GroupingSetCube = 4, + GroupingSetSets = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum CteMaterialize { + CtematerializeUndefined = 0, + Default = 1, + Always = 2, + Never = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SetOperation { + Undefined = 0, + SetopNone = 1, + SetopUnion = 2, + SetopIntersect = 3, + SetopExcept = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ObjectType { + Undefined = 0, + ObjectAccessMethod = 1, + ObjectAggregate = 2, + ObjectAmop = 3, + ObjectAmproc = 4, + ObjectAttribute = 5, + ObjectCast = 6, + ObjectColumn = 7, + ObjectCollation = 8, + ObjectConversion = 9, + ObjectDatabase = 10, + ObjectDefault = 11, + ObjectDefacl = 12, + ObjectDomain = 13, + ObjectDomconstraint = 14, + ObjectEventTrigger = 15, + ObjectExtension = 16, + ObjectFdw = 17, + ObjectForeignServer = 18, + ObjectForeignTable = 19, + ObjectFunction = 20, + ObjectIndex = 21, + ObjectLanguage = 22, + ObjectLargeobject = 23, + ObjectMatview = 24, + ObjectOpclass = 25, + ObjectOperator = 26, + ObjectOpfamily = 27, + ObjectPolicy = 28, + ObjectProcedure = 29, + ObjectPublication = 30, + ObjectPublicationRel = 31, + ObjectRole = 32, + ObjectRoutine = 33, + ObjectRule = 34, + ObjectSchema = 35, + ObjectSequence = 36, + ObjectSubscription = 37, + ObjectStatisticExt = 38, + ObjectTabconstraint = 39, + ObjectTable = 40, + ObjectTablespace = 41, + ObjectTransform = 42, + ObjectTrigger = 43, + ObjectTsconfiguration = 44, + ObjectTsdictionary = 45, + ObjectTsparser = 46, + ObjectTstemplate = 47, + ObjectType = 48, + ObjectUserMapping = 49, + ObjectView = 50, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum DropBehavior { + Undefined = 0, + DropRestrict = 1, + DropCascade = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AlterTableType { + Undefined = 0, + AtAddColumn = 1, + AtAddColumnRecurse = 2, + AtAddColumnToView = 3, + AtColumnDefault = 4, + AtCookedColumnDefault = 5, + AtDropNotNull = 6, + AtSetNotNull = 7, + AtDropExpression = 8, + AtCheckNotNull = 9, + AtSetStatistics = 10, + AtSetOptions = 11, + AtResetOptions = 12, + AtSetStorage = 13, + AtDropColumn = 14, + AtDropColumnRecurse = 15, + AtAddIndex = 16, + AtReAddIndex = 17, + AtAddConstraint = 18, + AtAddConstraintRecurse = 19, + AtReAddConstraint = 20, + AtReAddDomainConstraint = 21, + AtAlterConstraint = 22, + AtValidateConstraint = 23, + AtValidateConstraintRecurse = 24, + AtAddIndexConstraint = 25, + AtDropConstraint = 26, + AtDropConstraintRecurse = 27, + AtReAddComment = 28, + AtAlterColumnType = 29, + AtAlterColumnGenericOptions = 30, + AtChangeOwner = 31, + AtClusterOn = 32, + AtDropCluster = 33, + AtSetLogged = 34, + AtSetUnLogged = 35, + AtDropOids = 36, + AtSetTableSpace = 37, + AtSetRelOptions = 38, + AtResetRelOptions = 39, + AtReplaceRelOptions = 40, + AtEnableTrig = 41, + AtEnableAlwaysTrig = 42, + AtEnableReplicaTrig = 43, + AtDisableTrig = 44, + AtEnableTrigAll = 45, + AtDisableTrigAll = 46, + AtEnableTrigUser = 47, + AtDisableTrigUser = 48, + AtEnableRule = 49, + AtEnableAlwaysRule = 50, + AtEnableReplicaRule = 51, + AtDisableRule = 52, + AtAddInherit = 53, + AtDropInherit = 54, + AtAddOf = 55, + AtDropOf = 56, + AtReplicaIdentity = 57, + AtEnableRowSecurity = 58, + AtDisableRowSecurity = 59, + AtForceRowSecurity = 60, + AtNoForceRowSecurity = 61, + AtGenericOptions = 62, + AtAttachPartition = 63, + AtDetachPartition = 64, + AtAddIdentity = 65, + AtSetIdentity = 66, + AtDropIdentity = 67, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum GrantTargetType { + Undefined = 0, + AclTargetObject = 1, + AclTargetAllInSchema = 2, + AclTargetDefaults = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum VariableSetKind { + Undefined = 0, + VarSetValue = 1, + VarSetDefault = 2, + VarSetCurrent = 3, + VarSetMulti = 4, + VarReset = 5, + VarResetAll = 6, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ConstrType { + Undefined = 0, + ConstrNull = 1, + ConstrNotnull = 2, + ConstrDefault = 3, + ConstrIdentity = 4, + ConstrGenerated = 5, + ConstrCheck = 6, + ConstrPrimary = 7, + ConstrUnique = 8, + ConstrExclusion = 9, + ConstrForeign = 10, + ConstrAttrDeferrable = 11, + ConstrAttrNotDeferrable = 12, + ConstrAttrDeferred = 13, + ConstrAttrImmediate = 14, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ImportForeignSchemaType { + Undefined = 0, + FdwImportSchemaAll = 1, + FdwImportSchemaLimitTo = 2, + FdwImportSchemaExcept = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum RoleStmtType { + Undefined = 0, + RolestmtRole = 1, + RolestmtUser = 2, + RolestmtGroup = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum FetchDirection { + Undefined = 0, + FetchForward = 1, + FetchBackward = 2, + FetchAbsolute = 3, + FetchRelative = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum FunctionParameterMode { + Undefined = 0, + FuncParamIn = 1, + FuncParamOut = 2, + FuncParamInout = 3, + FuncParamVariadic = 4, + FuncParamTable = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum TransactionStmtKind { + Undefined = 0, + TransStmtBegin = 1, + TransStmtStart = 2, + TransStmtCommit = 3, + TransStmtRollback = 4, + TransStmtSavepoint = 5, + TransStmtRelease = 6, + TransStmtRollbackTo = 7, + TransStmtPrepare = 8, + TransStmtCommitPrepared = 9, + TransStmtRollbackPrepared = 10, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ViewCheckOption { + Undefined = 0, + NoCheckOption = 1, + LocalCheckOption = 2, + CascadedCheckOption = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ClusterOption { + Undefined = 0, + CluoptRecheck = 1, + CluoptVerbose = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum DiscardMode { + Undefined = 0, + DiscardAll = 1, + DiscardPlans = 2, + DiscardSequences = 3, + DiscardTemp = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ReindexObjectType { + Undefined = 0, + ReindexObjectIndex = 1, + ReindexObjectTable = 2, + ReindexObjectSchema = 3, + ReindexObjectSystem = 4, + ReindexObjectDatabase = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AlterTsConfigType { + AlterTsconfigTypeUndefined = 0, + AlterTsconfigAddMapping = 1, + AlterTsconfigAlterMappingForToken = 2, + AlterTsconfigReplaceDict = 3, + AlterTsconfigReplaceDictForToken = 4, + AlterTsconfigDropMapping = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AlterSubscriptionType { + Undefined = 0, + AlterSubscriptionOptions = 1, + AlterSubscriptionConnection = 2, + AlterSubscriptionPublication = 3, + AlterSubscriptionRefresh = 4, + AlterSubscriptionEnabled = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum OnCommitAction { + Undefined = 0, + OncommitNoop = 1, + OncommitPreserveRows = 2, + OncommitDeleteRows = 3, + OncommitDrop = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum ParamKind { + Undefined = 0, + ParamExtern = 1, + ParamExec = 2, + ParamSublink = 3, + ParamMultiexpr = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum CoercionContext { + Undefined = 0, + CoercionImplicit = 1, + CoercionAssignment = 2, + CoercionExplicit = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum CoercionForm { + Undefined = 0, + CoerceExplicitCall = 1, + CoerceExplicitCast = 2, + CoerceImplicitCast = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum BoolExprType { + Undefined = 0, + AndExpr = 1, + OrExpr = 2, + NotExpr = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SubLinkType { + Undefined = 0, + ExistsSublink = 1, + AllSublink = 2, + AnySublink = 3, + RowcompareSublink = 4, + ExprSublink = 5, + MultiexprSublink = 6, + ArraySublink = 7, + CteSublink = 8, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum RowCompareType { + Undefined = 0, + RowcompareLt = 1, + RowcompareLe = 2, + RowcompareEq = 3, + RowcompareGe = 4, + RowcompareGt = 5, + RowcompareNe = 6, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum MinMaxOp { + Undefined = 0, + IsGreatest = 1, + IsLeast = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SqlValueFunctionOp { + SqlvalueFunctionOpUndefined = 0, + SvfopCurrentDate = 1, + SvfopCurrentTime = 2, + SvfopCurrentTimeN = 3, + SvfopCurrentTimestamp = 4, + SvfopCurrentTimestampN = 5, + SvfopLocaltime = 6, + SvfopLocaltimeN = 7, + SvfopLocaltimestamp = 8, + SvfopLocaltimestampN = 9, + SvfopCurrentRole = 10, + SvfopCurrentUser = 11, + SvfopUser = 12, + SvfopSessionUser = 13, + SvfopCurrentCatalog = 14, + SvfopCurrentSchema = 15, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum XmlExprOp { + Undefined = 0, + IsXmlconcat = 1, + IsXmlelement = 2, + IsXmlforest = 3, + IsXmlparse = 4, + IsXmlpi = 5, + IsXmlroot = 6, + IsXmlserialize = 7, + IsDocument = 8, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum XmlOptionType { + Undefined = 0, + XmloptionDocument = 1, + XmloptionContent = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum NullTestType { + Undefined = 0, + IsNull = 1, + IsNotNull = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum BoolTestType { + Undefined = 0, + IsTrue = 1, + IsNotTrue = 2, + IsFalse = 3, + IsNotFalse = 4, + IsUnknown = 5, + IsNotUnknown = 6, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum CmdType { + Undefined = 0, + CmdUnknown = 1, + CmdSelect = 2, + CmdUpdate = 3, + CmdInsert = 4, + CmdDelete = 5, + CmdUtility = 6, + CmdNothing = 7, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum JoinType { + Undefined = 0, + JoinInner = 1, + JoinLeft = 2, + JoinFull = 3, + JoinRight = 4, + JoinSemi = 5, + JoinAnti = 6, + JoinUniqueOuter = 7, + JoinUniqueInner = 8, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AggStrategy { + Undefined = 0, + AggPlain = 1, + AggSorted = 2, + AggHashed = 3, + AggMixed = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum AggSplit { + Undefined = 0, + AggsplitSimple = 1, + AggsplitInitialSerial = 2, + AggsplitFinalDeserial = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SetOpCmd { + Undefined = 0, + SetopcmdIntersect = 1, + SetopcmdIntersectAll = 2, + SetopcmdExcept = 3, + SetopcmdExceptAll = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum SetOpStrategy { + Undefined = 0, + SetopSorted = 1, + SetopHashed = 2, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum OnConflictAction { + Undefined = 0, + OnconflictNone = 1, + OnconflictNothing = 2, + OnconflictUpdate = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum LimitOption { + Undefined = 0, + Default = 1, + Count = 2, + WithTies = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum LockClauseStrength { + Undefined = 0, + LcsNone = 1, + LcsForkeyshare = 2, + LcsForshare = 3, + LcsFornokeyupdate = 4, + LcsForupdate = 5, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum LockWaitPolicy { + Undefined = 0, + LockWaitBlock = 1, + LockWaitSkip = 2, + LockWaitError = 3, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum LockTupleMode { + Undefined = 0, + LockTupleKeyShare = 1, + LockTupleShare = 2, + LockTupleNoKeyExclusive = 3, + LockTupleExclusive = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum KeywordKind { + NoKeyword = 0, + UnreservedKeyword = 1, + ColNameKeyword = 2, + TypeFuncNameKeyword = 3, + ReservedKeyword = 4, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(i32)] +pub enum Token { + Nul = 0, + /// Single-character tokens that are returned 1:1 (identical with "self" list in scan.l) + /// Either supporting syntax, or single-character operators (some can be both) + /// Also see + /// + /// "%" + Ascii37 = 37, + /// "(" + Ascii40 = 40, + /// ")" + Ascii41 = 41, + /// "*" + Ascii42 = 42, + /// "+" + Ascii43 = 43, + /// "," + Ascii44 = 44, + /// "-" + Ascii45 = 45, + /// "." + Ascii46 = 46, + /// "/" + Ascii47 = 47, + /// ":" + Ascii58 = 58, + /// ";" + Ascii59 = 59, + /// "<" + Ascii60 = 60, + /// "=" + Ascii61 = 61, + /// ">" + Ascii62 = 62, + /// "?" + Ascii63 = 63, + /// "[" + Ascii91 = 91, + /// "\" + Ascii92 = 92, + /// "]" + Ascii93 = 93, + /// "^" + Ascii94 = 94, + /// Named tokens in scan.l + Ident = 258, + Uident = 259, + Fconst = 260, + Sconst = 261, + Usconst = 262, + Bconst = 263, + Xconst = 264, + Op = 265, + Iconst = 266, + Param = 267, + Typecast = 268, + DotDot = 269, + ColonEquals = 270, + EqualsGreater = 271, + LessEquals = 272, + GreaterEquals = 273, + NotEquals = 274, + SqlComment = 275, + CComment = 276, + AbortP = 277, + AbsoluteP = 278, + Access = 279, + Action = 280, + AddP = 281, + Admin = 282, + After = 283, + Aggregate = 284, + All = 285, + Also = 286, + Alter = 287, + Always = 288, + Analyse = 289, + Analyze = 290, + And = 291, + Any = 292, + Array = 293, + As = 294, + Asc = 295, + Assertion = 296, + Assignment = 297, + Asymmetric = 298, + At = 299, + Attach = 300, + Attribute = 301, + Authorization = 302, + Backward = 303, + Before = 304, + BeginP = 305, + Between = 306, + Bigint = 307, + Binary = 308, + Bit = 309, + BooleanP = 310, + Both = 311, + By = 312, + Cache = 313, + Call = 314, + Called = 315, + Cascade = 316, + Cascaded = 317, + Case = 318, + Cast = 319, + CatalogP = 320, + Chain = 321, + CharP = 322, + Character = 323, + Characteristics = 324, + Check = 325, + Checkpoint = 326, + Class = 327, + Close = 328, + Cluster = 329, + Coalesce = 330, + Collate = 331, + Collation = 332, + Column = 333, + Columns = 334, + Comment = 335, + Comments = 336, + Commit = 337, + Committed = 338, + Concurrently = 339, + Configuration = 340, + Conflict = 341, + Connection = 342, + Constraint = 343, + Constraints = 344, + ContentP = 345, + ContinueP = 346, + ConversionP = 347, + Copy = 348, + Cost = 349, + Create = 350, + Cross = 351, + Csv = 352, + Cube = 353, + CurrentP = 354, + CurrentCatalog = 355, + CurrentDate = 356, + CurrentRole = 357, + CurrentSchema = 358, + CurrentTime = 359, + CurrentTimestamp = 360, + CurrentUser = 361, + Cursor = 362, + Cycle = 363, + DataP = 364, + Database = 365, + DayP = 366, + Deallocate = 367, + Dec = 368, + DecimalP = 369, + Declare = 370, + Default = 371, + Defaults = 372, + Deferrable = 373, + Deferred = 374, + Definer = 375, + DeleteP = 376, + Delimiter = 377, + Delimiters = 378, + Depends = 379, + Desc = 380, + Detach = 381, + Dictionary = 382, + DisableP = 383, + Discard = 384, + Distinct = 385, + Do = 386, + DocumentP = 387, + DomainP = 388, + DoubleP = 389, + Drop = 390, + Each = 391, + Else = 392, + EnableP = 393, + Encoding = 394, + Encrypted = 395, + EndP = 396, + EnumP = 397, + Escape = 398, + Event = 399, + Except = 400, + Exclude = 401, + Excluding = 402, + Exclusive = 403, + Execute = 404, + Exists = 405, + Explain = 406, + Expression = 407, + Extension = 408, + External = 409, + Extract = 410, + FalseP = 411, + Family = 412, + Fetch = 413, + Filter = 414, + FirstP = 415, + FloatP = 416, + Following = 417, + For = 418, + Force = 419, + Foreign = 420, + Forward = 421, + Freeze = 422, + From = 423, + Full = 424, + Function = 425, + Functions = 426, + Generated = 427, + Global = 428, + Grant = 429, + Granted = 430, + Greatest = 431, + GroupP = 432, + Grouping = 433, + Groups = 434, + Handler = 435, + Having = 436, + HeaderP = 437, + Hold = 438, + HourP = 439, + IdentityP = 440, + IfP = 441, + Ilike = 442, + Immediate = 443, + Immutable = 444, + ImplicitP = 445, + ImportP = 446, + InP = 447, + Include = 448, + Including = 449, + Increment = 450, + Index = 451, + Indexes = 452, + Inherit = 453, + Inherits = 454, + Initially = 455, + InlineP = 456, + InnerP = 457, + Inout = 458, + InputP = 459, + Insensitive = 460, + Insert = 461, + Instead = 462, + IntP = 463, + Integer = 464, + Intersect = 465, + Interval = 466, + Into = 467, + Invoker = 468, + Is = 469, + Isnull = 470, + Isolation = 471, + Join = 472, + Key = 473, + Label = 474, + Language = 475, + LargeP = 476, + LastP = 477, + LateralP = 478, + Leading = 479, + Leakproof = 480, + Least = 481, + Left = 482, + Level = 483, + Like = 484, + Limit = 485, + Listen = 486, + Load = 487, + Local = 488, + Localtime = 489, + Localtimestamp = 490, + Location = 491, + LockP = 492, + Locked = 493, + Logged = 494, + Mapping = 495, + Match = 496, + Materialized = 497, + Maxvalue = 498, + Method = 499, + MinuteP = 500, + Minvalue = 501, + Mode = 502, + MonthP = 503, + Move = 504, + NameP = 505, + Names = 506, + National = 507, + Natural = 508, + Nchar = 509, + New = 510, + Next = 511, + Nfc = 512, + Nfd = 513, + Nfkc = 514, + Nfkd = 515, + No = 516, + None = 517, + Normalize = 518, + Normalized = 519, + Not = 520, + Nothing = 521, + Notify = 522, + Notnull = 523, + Nowait = 524, + NullP = 525, + Nullif = 526, + NullsP = 527, + Numeric = 528, + ObjectP = 529, + Of = 530, + Off = 531, + Offset = 532, + Oids = 533, + Old = 534, + On = 535, + Only = 536, + Operator = 537, + Option = 538, + Options = 539, + Or = 540, + Order = 541, + Ordinality = 542, + Others = 543, + OutP = 544, + OuterP = 545, + Over = 546, + Overlaps = 547, + Overlay = 548, + Overriding = 549, + Owned = 550, + Owner = 551, + Parallel = 552, + Parser = 553, + Partial = 554, + Partition = 555, + Passing = 556, + Password = 557, + Placing = 558, + Plans = 559, + Policy = 560, + Position = 561, + Preceding = 562, + Precision = 563, + Preserve = 564, + Prepare = 565, + Prepared = 566, + Primary = 567, + Prior = 568, + Privileges = 569, + Procedural = 570, + Procedure = 571, + Procedures = 572, + Program = 573, + Publication = 574, + Quote = 575, + Range = 576, + Read = 577, + Real = 578, + Reassign = 579, + Recheck = 580, + Recursive = 581, + Ref = 582, + References = 583, + Referencing = 584, + Refresh = 585, + Reindex = 586, + RelativeP = 587, + Release = 588, + Rename = 589, + Repeatable = 590, + Replace = 591, + Replica = 592, + Reset = 593, + Restart = 594, + Restrict = 595, + Returning = 596, + Returns = 597, + Revoke = 598, + Right = 599, + Role = 600, + Rollback = 601, + Rollup = 602, + Routine = 603, + Routines = 604, + Row = 605, + Rows = 606, + Rule = 607, + Savepoint = 608, + Schema = 609, + Schemas = 610, + Scroll = 611, + Search = 612, + SecondP = 613, + Security = 614, + Select = 615, + Sequence = 616, + Sequences = 617, + Serializable = 618, + Server = 619, + Session = 620, + SessionUser = 621, + Set = 622, + Sets = 623, + Setof = 624, + Share = 625, + Show = 626, + Similar = 627, + Simple = 628, + Skip = 629, + Smallint = 630, + Snapshot = 631, + Some = 632, + SqlP = 633, + Stable = 634, + StandaloneP = 635, + Start = 636, + Statement = 637, + Statistics = 638, + Stdin = 639, + Stdout = 640, + Storage = 641, + Stored = 642, + StrictP = 643, + StripP = 644, + Subscription = 645, + Substring = 646, + Support = 647, + Symmetric = 648, + Sysid = 649, + SystemP = 650, + Table = 651, + Tables = 652, + Tablesample = 653, + Tablespace = 654, + Temp = 655, + Template = 656, + Temporary = 657, + TextP = 658, + Then = 659, + Ties = 660, + Time = 661, + Timestamp = 662, + To = 663, + Trailing = 664, + Transaction = 665, + Transform = 666, + Treat = 667, + Trigger = 668, + Trim = 669, + TrueP = 670, + Truncate = 671, + Trusted = 672, + TypeP = 673, + TypesP = 674, + Uescape = 675, + Unbounded = 676, + Uncommitted = 677, + Unencrypted = 678, + Union = 679, + Unique = 680, + Unknown = 681, + Unlisten = 682, + Unlogged = 683, + Until = 684, + Update = 685, + User = 686, + Using = 687, + Vacuum = 688, + Valid = 689, + Validate = 690, + Validator = 691, + ValueP = 692, + Values = 693, + Varchar = 694, + Variadic = 695, + Varying = 696, + Verbose = 697, + VersionP = 698, + View = 699, + Views = 700, + Volatile = 701, + When = 702, + Where = 703, + WhitespaceP = 704, + Window = 705, + With = 706, + Within = 707, + Without = 708, + Work = 709, + Wrapper = 710, + Write = 711, + XmlP = 712, + Xmlattributes = 713, + Xmlconcat = 714, + Xmlelement = 715, + Xmlexists = 716, + Xmlforest = 717, + Xmlnamespaces = 718, + Xmlparse = 719, + Xmlpi = 720, + Xmlroot = 721, + Xmlserialize = 722, + Xmltable = 723, + YearP = 724, + YesP = 725, + Zone = 726, + NotLa = 727, + NullsLa = 728, + WithLa = 729, + Postfixop = 730, + Uminus = 731, +} diff --git a/src/tools/rustfmt/tests/target/struct_field_doc_comment.rs b/src/tools/rustfmt/tests/target/struct_field_doc_comment.rs new file mode 100644 index 00000000000..ebb01a668f4 --- /dev/null +++ b/src/tools/rustfmt/tests/target/struct_field_doc_comment.rs @@ -0,0 +1,69 @@ +// #5215 +struct MyTuple( + /// Doc Comments + /* TODO note to add more to Doc Comments */ + u32, + /// Doc Comments + // TODO note + u64, +); + +struct MyTuple( + #[cfg(unix)] // some comment + u64, + #[cfg(not(unix))] /*block comment */ u32, +); + +struct MyTuple( + #[cfg(unix)] + // some comment + u64, + #[cfg(not(unix))] + /*block comment */ + u32, +); + +struct MyTuple( + #[cfg(unix)] // some comment + pub u64, + #[cfg(not(unix))] /*block comment */ pub(crate) u32, +); + +struct MyTuple( + /// Doc Comments + /* TODO note to add more to Doc Comments */ + pub u32, + /// Doc Comments + // TODO note + pub(crate) u64, +); + +struct MyStruct { + #[cfg(unix)] // some comment + a: u64, + #[cfg(not(unix))] /*block comment */ b: u32, +} + +struct MyStruct { + #[cfg(unix)] // some comment + pub a: u64, + #[cfg(not(unix))] /*block comment */ pub(crate) b: u32, +} + +struct MyStruct { + /// Doc Comments + /* TODO note to add more to Doc Comments */ + a: u32, + /// Doc Comments + // TODO note + b: u64, +} + +struct MyStruct { + /// Doc Comments + /* TODO note to add more to Doc Comments */ + pub a: u32, + /// Doc Comments + // TODO note + pub(crate) b: u64, +}