summaryrefslogtreecommitdiffstats
path: root/third_party/rust/displaydoc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/displaydoc
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/displaydoc')
-rw-r--r--third_party/rust/displaydoc/.cargo-checksum.json1
-rw-r--r--third_party/rust/displaydoc/CHANGELOG.md39
-rw-r--r--third_party/rust/displaydoc/Cargo.lock255
-rw-r--r--third_party/rust/displaydoc/Cargo.toml98
-rw-r--r--third_party/rust/displaydoc/LICENSE-APACHE201
-rw-r--r--third_party/rust/displaydoc/LICENSE-MIT23
-rw-r--r--third_party/rust/displaydoc/README.md99
-rw-r--r--third_party/rust/displaydoc/README.tpl23
-rw-r--r--third_party/rust/displaydoc/examples/simple.rs36
-rw-r--r--third_party/rust/displaydoc/src/attr.rs134
-rw-r--r--third_party/rust/displaydoc/src/expand.rs145
-rw-r--r--third_party/rust/displaydoc/src/fmt.rs159
-rw-r--r--third_party/rust/displaydoc/src/lib.rs122
-rw-r--r--third_party/rust/displaydoc/tests/compile_tests.rs29
-rw-r--r--third_party/rust/displaydoc/tests/happy.rs152
-rw-r--r--third_party/rust/displaydoc/tests/no_std/enum_prefix.rs36
-rw-r--r--third_party/rust/displaydoc/tests/no_std/enum_prefix_missing.rs35
-rw-r--r--third_party/rust/displaydoc/tests/no_std/enum_prefix_missing.stderr19
-rw-r--r--third_party/rust/displaydoc/tests/no_std/multi_line.rs37
-rw-r--r--third_party/rust/displaydoc/tests/no_std/multi_line.stderr19
-rw-r--r--third_party/rust/displaydoc/tests/no_std/multi_line_allow.rs38
-rw-r--r--third_party/rust/displaydoc/tests/no_std/with.rs32
-rw-r--r--third_party/rust/displaydoc/tests/no_std/without.rs28
-rw-r--r--third_party/rust/displaydoc/tests/no_std/without.stderr19
-rw-r--r--third_party/rust/displaydoc/tests/num_in_field.rs22
-rw-r--r--third_party/rust/displaydoc/tests/std/enum_prefix.rs36
-rw-r--r--third_party/rust/displaydoc/tests/std/enum_prefix_missing.rs35
-rw-r--r--third_party/rust/displaydoc/tests/std/enum_prefix_missing.stderr19
-rw-r--r--third_party/rust/displaydoc/tests/std/multi_line.rs37
-rw-r--r--third_party/rust/displaydoc/tests/std/multi_line.stderr19
-rw-r--r--third_party/rust/displaydoc/tests/std/multi_line_allow.rs38
-rw-r--r--third_party/rust/displaydoc/tests/std/multiple.rs38
-rw-r--r--third_party/rust/displaydoc/tests/std/without.rs28
-rw-r--r--third_party/rust/displaydoc/tests/std/without.stderr19
34 files changed, 2070 insertions, 0 deletions
diff --git a/third_party/rust/displaydoc/.cargo-checksum.json b/third_party/rust/displaydoc/.cargo-checksum.json
new file mode 100644
index 0000000000..5a1aaf0685
--- /dev/null
+++ b/third_party/rust/displaydoc/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"CHANGELOG.md":"1c4dbc1c48e7b5701be1d62f4628ecc1f933f70e43b5e8040203e8d98f53271d","Cargo.lock":"5a48a896619a85847e026ad6dde382c16385ca046f44eead947dbe8a787824be","Cargo.toml":"fcdfd7e2b923eb8cbf3bdf47da18cc26c17c5d530fe3704c5f7753d5541a9c2e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"a83258f76a3af3aa3ca42731473d9a2789858b25e4e153fe3dbbd6614328bdcd","README.tpl":"974701ae7f6d238bd325dd32104a5265841e79a9b79a595f7fdd964711c0cd19","examples/simple.rs":"bca524b36621ac56044cbe3eebf8892f7a3b398fd8f257fc67b17b26ae34bfbf","src/attr.rs":"a41e416d4d2a854677052f18517549a20d05cccffa04a24398107237aff3c415","src/expand.rs":"52bbf8fca0b3cb70e3a5e4ec763d294230c0afdf47612b32e46ca5fbee64154d","src/fmt.rs":"9c13cbcd337066614bc26ecfd36ea9730c9b8099083a9a7ffd79f8dc17e414f1","src/lib.rs":"168a0b9ee9dda0b26b7c68ed13c92b9e8aaf0587110b9751ede12bbfbb58be76","tests/compile_tests.rs":"935609d68eaa52e0ce9f29b3dae649787cd1f540f9b4bbadcbefcb8a0febcfc8","tests/happy.rs":"1b4c119184ca3914684c1cafaa25a8fbb9e60ef45eb257ad7ac86b8b2d7a3856","tests/no_std/enum_prefix.rs":"12401753bb44e408e1940223e8c295e63f9ddaaa114b634aac1e057a771d7eee","tests/no_std/enum_prefix_missing.rs":"8531d335c3bb7036c2adecf9af6507c46017ef1d78e222a7528396bd78316002","tests/no_std/enum_prefix_missing.stderr":"8b9f12979bdd0f88d57c5f1217accb7268eb26ee434493fe454cf89be93394b1","tests/no_std/multi_line.rs":"a87214677020029f526cdc7024d38c738f4cbba335d215dbab5cbf394118700a","tests/no_std/multi_line.stderr":"a93b9dba31f879df465fffb0cbc8b962a07181e4e94a4ef3cf34fc5422eee4a8","tests/no_std/multi_line_allow.rs":"737ea03df1c75a1adcd375a84abcc654feb39781faf9964cdfef4b3253ce1376","tests/no_std/with.rs":"c13a2d4701606a5bacfa31593c16d6417f829259dd28dfa129b729a6f8fafac2","tests/no_std/without.rs":"992344f252e856ce4979e50cb19fdb6f4dc92fb8594e2cf26f47c4ff8124f2cd","tests/no_std/without.stderr":"811331272d445ebbc00019ff62d13cd0614bd8a83153a96136911f1a30221b20","tests/num_in_field.rs":"d0bc3ba7f9aea17d3abee4ac05afe6d4a0112d3527698791e1eeaa3464e2b1d4","tests/std/enum_prefix.rs":"12401753bb44e408e1940223e8c295e63f9ddaaa114b634aac1e057a771d7eee","tests/std/enum_prefix_missing.rs":"8531d335c3bb7036c2adecf9af6507c46017ef1d78e222a7528396bd78316002","tests/std/enum_prefix_missing.stderr":"6c5eff42d8ae6c06aceff7214b570ee179329d427f6a2117097a381eed2f2f17","tests/std/multi_line.rs":"a87214677020029f526cdc7024d38c738f4cbba335d215dbab5cbf394118700a","tests/std/multi_line.stderr":"af08a172042d4c7bce308f49044c5648896ea0707fbdfa9b971bcaf951584c77","tests/std/multi_line_allow.rs":"737ea03df1c75a1adcd375a84abcc654feb39781faf9964cdfef4b3253ce1376","tests/std/multiple.rs":"f59ea8ad70b9f6cc72e66d40832c8f8ee0402b170af0fb1443615ef6af9380dd","tests/std/without.rs":"992344f252e856ce4979e50cb19fdb6f4dc92fb8594e2cf26f47c4ff8124f2cd","tests/std/without.stderr":"43bd84eca8a361b1fcfc258014115dd12080357e15b640dd7ac6f42f59eee6ca"},"package":"3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886"} \ No newline at end of file
diff --git a/third_party/rust/displaydoc/CHANGELOG.md b/third_party/rust/displaydoc/CHANGELOG.md
new file mode 100644
index 0000000000..ed100925eb
--- /dev/null
+++ b/third_party/rust/displaydoc/CHANGELOG.md
@@ -0,0 +1,39 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+<!-- next-header -->
+
+## [Unreleased] - ReleaseDate
+
+# [0.2.3] - 2021-07-16
+## Added
+- Added `#[displaydoc("..")]` attribute for overriding a doc comment
+
+# [0.2.2] - 2021-07-01
+## Added
+- Added prefix feature to use the doc comment from an enum and prepend it
+ before the error message from each variant.
+
+# [0.2.1] - 2021-03-26
+## Added
+- Added opt in support for ignoring extra doc attributes
+
+# [0.2.0] - 2021-03-16
+## Changed
+
+- (BREAKING) disallow multiple `doc` attributes in display impl
+ [https://github.com/yaahc/displaydoc/pull/22]. Allowing and ignoring extra
+ doc attributes made it too easy to accidentally create a broken display
+ implementation with missing context without realizing it, this change turns
+ that into a hard error and directs users towards block comments if multiple
+ lines are needed.
+
+<!-- next-url -->
+[Unreleased]: https://github.com/yaahc/displaydoc/compare/v0.2.3...HEAD
+[0.2.3]: https://github.com/yaahc/displaydoc/compare/v0.2.2...v0.2.3
+[0.2.2]: https://github.com/yaahc/displaydoc/compare/v0.2.1...v0.2.2
+[0.2.1]: https://github.com/yaahc/displaydoc/compare/v0.2.0...v0.2.1
+[0.2.0]: https://github.com/yaahc/displaydoc/releases/tag/v0.2.0
diff --git a/third_party/rust/displaydoc/Cargo.lock b/third_party/rust/displaydoc/Cargo.lock
new file mode 100644
index 0000000000..ea4e30c7c0
--- /dev/null
+++ b/third_party/rust/displaydoc/Cargo.lock
@@ -0,0 +1,255 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "ansi_term"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "ctor"
+version = "0.1.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e98e2ad1a782e33928b96fc3948e7c355e5af34ba4de7670fe8bac2a3b2006d"
+dependencies = [
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "difference"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
+
+[[package]]
+name = "displaydoc"
+version = "0.2.3"
+dependencies = [
+ "libc",
+ "pretty_assertions",
+ "proc-macro2",
+ "quote",
+ "rustversion",
+ "static_assertions",
+ "syn",
+ "thiserror",
+ "trybuild",
+]
+
+[[package]]
+name = "glob"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
+
+[[package]]
+name = "itoa"
+version = "0.4.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
+name = "libc"
+version = "0.2.93"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
+
+[[package]]
+name = "output_vt100"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "pretty_assertions"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427"
+dependencies = [
+ "ansi_term",
+ "ctor",
+ "difference",
+ "output_vt100",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
+dependencies = [
+ "unicode-xid",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd"
+
+[[package]]
+name = "ryu"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
+
+[[package]]
+name = "serde"
+version = "1.0.125"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.125"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.64"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "static_assertions"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3"
+
+[[package]]
+name = "syn"
+version = "1.0.68"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
+]
+
+[[package]]
+name = "termcolor"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "toml"
+version = "0.5.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "trybuild"
+version = "1.0.41"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "99471a206425fba51842a9186315f32d91c56eadc21ea4c21f847b59cf778f8b"
+dependencies = [
+ "glob",
+ "lazy_static",
+ "serde",
+ "serde_json",
+ "termcolor",
+ "toml",
+]
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/third_party/rust/displaydoc/Cargo.toml b/third_party/rust/displaydoc/Cargo.toml
new file mode 100644
index 0000000000..9803ab6e88
--- /dev/null
+++ b/third_party/rust/displaydoc/Cargo.toml
@@ -0,0 +1,98 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+edition = "2018"
+name = "displaydoc"
+version = "0.2.3"
+authors = ["Jane Lusby <jlusby@yaah.dev>"]
+description = "A derive macro for implementing the display Trait via a doc comment and string interpolation\n"
+homepage = "https://github.com/yaahc/displaydoc"
+documentation = "https://docs.rs/displaydoc"
+readme = "README.md"
+keywords = ["display", "derive"]
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/yaahc/displaydoc"
+[package.metadata.docs.rs]
+all-features = true
+rustdoc-args = ["--cfg", "docsrs"]
+
+[package.metadata.release]
+no-dev-version = true
+
+[[package.metadata.release.pre-release-replacements]]
+file = "CHANGELOG.md"
+replace = "{{version}}"
+search = "Unreleased"
+
+[[package.metadata.release.pre-release-replacements]]
+exactly = 1
+file = "src/lib.rs"
+replace = "#![doc(html_root_url = \"https://docs.rs/{{crate_name}}/{{version}}\")]"
+search = "#!\\[doc\\(html_root_url.*"
+
+[[package.metadata.release.pre-release-replacements]]
+file = "CHANGELOG.md"
+replace = "{{date}}"
+search = "ReleaseDate"
+
+[[package.metadata.release.pre-release-replacements]]
+exactly = 1
+file = "CHANGELOG.md"
+replace = "<!-- next-header -->\n\n## [Unreleased] - ReleaseDate"
+search = "<!-- next-header -->"
+
+[[package.metadata.release.pre-release-replacements]]
+exactly = 1
+file = "CHANGELOG.md"
+replace = "...{{tag_name}}"
+search = "\\.\\.\\.HEAD"
+
+[[package.metadata.release.pre-release-replacements]]
+exactly = 1
+file = "CHANGELOG.md"
+replace = "<!-- next-url -->\n[Unreleased]: https://github.com/yaahc/{{crate_name}}/compare/{{tag_name}}...HEAD"
+search = "<!-- next-url -->"
+
+[lib]
+path = "src/lib.rs"
+proc-macro = true
+[dependencies.proc-macro2]
+version = "1.0"
+
+[dependencies.quote]
+version = "1.0"
+
+[dependencies.syn]
+version = "1.0"
+[dev-dependencies.libc]
+version = "0.2"
+default-features = false
+
+[dev-dependencies.pretty_assertions]
+version = "0.6.1"
+
+[dev-dependencies.rustversion]
+version = "1.0.0"
+
+[dev-dependencies.static_assertions]
+version = "0.3.4"
+
+[dev-dependencies.thiserror]
+version = "1.0.24"
+
+[dev-dependencies.trybuild]
+version = "1.0"
+
+[features]
+default = ["std"]
+std = []
diff --git a/third_party/rust/displaydoc/LICENSE-APACHE b/third_party/rust/displaydoc/LICENSE-APACHE
new file mode 100644
index 0000000000..16fe87b06e
--- /dev/null
+++ b/third_party/rust/displaydoc/LICENSE-APACHE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/third_party/rust/displaydoc/LICENSE-MIT b/third_party/rust/displaydoc/LICENSE-MIT
new file mode 100644
index 0000000000..31aa79387f
--- /dev/null
+++ b/third_party/rust/displaydoc/LICENSE-MIT
@@ -0,0 +1,23 @@
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/third_party/rust/displaydoc/README.md b/third_party/rust/displaydoc/README.md
new file mode 100644
index 0000000000..990a1385e4
--- /dev/null
+++ b/third_party/rust/displaydoc/README.md
@@ -0,0 +1,99 @@
+derive(Display) /// `From<docs>`
+===============
+
+[![Latest Version](https://img.shields.io/crates/v/displaydoc.svg)](https://crates.io/crates/displaydoc)
+[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/displaydoc)
+
+This library provides a convenient derive macro for the standard library's
+[`core::fmt::Display`] trait.
+
+[`core::fmt::Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html
+
+```toml
+[dependencies]
+displaydoc = "0.2"
+```
+
+*Compiler support: requires rustc 1.31+*
+
+<br>
+
+### Example
+
+```rust
+use std::io;
+use displaydoc::Display;
+use thiserror::Error;
+
+#[derive(Display, Error, Debug)]
+pub enum DataStoreError {
+ /// data store disconnected
+ Disconnect(#[source] io::Error),
+ /// the data for key `{0}` is not available
+ Redaction(String),
+ /// invalid header (expected {expected:?}, found {found:?})
+ InvalidHeader {
+ expected: String,
+ found: String,
+ },
+ /// unknown data store error
+ Unknown,
+}
+```
+
+<br>
+
+### Details
+
+- A `Display` impl is generated for your type if you provide doc comment
+ messages on the struct or each variant of your enum, as shown above in the
+ example.
+
+ The messages support a shorthand for interpolating fields from the error.
+
+ - `/// {var}` ⟶ `write!("{}", self.var)`
+ - `/// {0}` ⟶ `write!("{}", self.0)`
+ - `/// {var:?}` ⟶ `write!("{:?}", self.var)`
+ - `/// {0:?}` ⟶ `write!("{:?}", self.0)`
+
+- Two optional attributes can be added to your types next to the derive:
+
+ - `#[ignore_extra_doc_attributes]` makes the macro ignore any doc
+ comment attributes (or `///` lines) after the first. Multi-line
+ comments using `///` are otherwise treated as an error, so use this
+ attribute or consider switching to block doc comments (`/** */`).
+
+ - `#[prefix_enum_doc_attributes]` combines the doc comment message on
+ your enum itself with the messages for each variant, in the format
+ “enum: variant”. When added to an enum, the doc comment on the enum
+ becomes mandatory. When added to any other type, it has no effect.
+
+- In case you want to have an independent doc comment, the
+ `#[displaydoc("...")` atrribute may be used on the variant or struct to
+ override it.
+
+<br>
+
+### FAQ
+
+1. **Is this crate `no_std` compatible?**
+ * Yes! This crate implements the `core::fmt::Display` trait not the `std::fmt::Display` trait so it should work in `std` and `no_std` environments. Just add `default-features = false`.
+
+2. **Does this crate work with `Path` and `PathBuf` via the `Display` trait?**
+ * Yuuup. This crate uses @dtolnay's [autoref specialization technique](https://github.com/dtolnay/case-studies/blob/master/autoref-specialization/README.md) to add a special trait for types to get the display impl, it then specializes for `Path` and `PathBuf` and when either of these types are found it calls `self.display()` to get a `std::path::Display<'_>` type which can be used with the Display format specifier!
+
+
+#### License
+
+<sup>
+Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
+2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
+</sup>
+
+<br>
+
+<sub>
+Unless you explicitly state otherwise, any contribution intentionally submitted
+for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
+be dual licensed as above, without any additional terms or conditions.
+</sub>
diff --git a/third_party/rust/displaydoc/README.tpl b/third_party/rust/displaydoc/README.tpl
new file mode 100644
index 0000000000..6206a9e7e6
--- /dev/null
+++ b/third_party/rust/displaydoc/README.tpl
@@ -0,0 +1,23 @@
+derive(Display) /// `From<docs>`
+===============
+
+[![Latest Version](https://img.shields.io/crates/v/displaydoc.svg)](https://crates.io/crates/displaydoc)
+[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/displaydoc)
+
+{{readme}}
+
+
+#### License
+
+<sup>
+Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
+2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
+</sup>
+
+<br>
+
+<sub>
+Unless you explicitly state otherwise, any contribution intentionally submitted
+for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
+be dual licensed as above, without any additional terms or conditions.
+</sub>
diff --git a/third_party/rust/displaydoc/examples/simple.rs b/third_party/rust/displaydoc/examples/simple.rs
new file mode 100644
index 0000000000..f4aad2131f
--- /dev/null
+++ b/third_party/rust/displaydoc/examples/simple.rs
@@ -0,0 +1,36 @@
+use displaydoc::Display;
+
+#[derive(Debug, Display)]
+pub enum DataStoreError {
+ /// data store disconnected
+ Disconnect,
+ /// the data for key `{0}` is not available
+ Redaction(String),
+ /// invalid header (expected {expected:?}, found {found:?})
+ InvalidHeader { expected: String, found: String },
+ /// unknown data store error
+ Unknown,
+}
+
+fn main() {
+ let disconnect = DataStoreError::Disconnect;
+ println!(
+ "Enum value `Disconnect` should be printed as:\n\t{}",
+ disconnect
+ );
+
+ let redaction = DataStoreError::Redaction(String::from("Dummy"));
+ println!(
+ "Enum value `Redaction` should be printed as:\n\t{}",
+ redaction
+ );
+
+ let invalid_header = DataStoreError::InvalidHeader {
+ expected: String::from("https"),
+ found: String::from("http"),
+ };
+ println!(
+ "Enum value `InvalidHeader` should be printed as:\n\t{}",
+ invalid_header
+ );
+}
diff --git a/third_party/rust/displaydoc/src/attr.rs b/third_party/rust/displaydoc/src/attr.rs
new file mode 100644
index 0000000000..e14593556c
--- /dev/null
+++ b/third_party/rust/displaydoc/src/attr.rs
@@ -0,0 +1,134 @@
+use proc_macro2::TokenStream;
+use quote::{quote, ToTokens};
+use syn::{Attribute, LitStr, Meta, Result};
+
+#[derive(Clone)]
+pub(crate) struct Display {
+ pub(crate) fmt: LitStr,
+ pub(crate) args: TokenStream,
+}
+
+pub(crate) struct VariantDisplay {
+ pub(crate) r#enum: Option<Display>,
+ pub(crate) variant: Display,
+}
+
+impl ToTokens for Display {
+ fn to_tokens(&self, tokens: &mut TokenStream) {
+ let fmt = &self.fmt;
+ let args = &self.args;
+ tokens.extend(quote! {
+ write!(formatter, #fmt #args)
+ });
+ }
+}
+
+impl ToTokens for VariantDisplay {
+ fn to_tokens(&self, tokens: &mut TokenStream) {
+ if let Some(ref r#enum) = self.r#enum {
+ r#enum.to_tokens(tokens);
+ tokens.extend(quote! { ?; write!(formatter, ": ")?; });
+ }
+ self.variant.to_tokens(tokens);
+ }
+}
+
+pub(crate) struct AttrsHelper {
+ ignore_extra_doc_attributes: bool,
+ prefix_enum_doc_attributes: bool,
+}
+
+impl AttrsHelper {
+ pub(crate) fn new(attrs: &[Attribute]) -> Self {
+ let ignore_extra_doc_attributes = attrs
+ .iter()
+ .any(|attr| attr.path.is_ident("ignore_extra_doc_attributes"));
+ let prefix_enum_doc_attributes = attrs
+ .iter()
+ .any(|attr| attr.path.is_ident("prefix_enum_doc_attributes"));
+
+ Self {
+ ignore_extra_doc_attributes,
+ prefix_enum_doc_attributes,
+ }
+ }
+
+ pub(crate) fn display(&self, attrs: &[Attribute]) -> Result<Option<Display>> {
+ let displaydoc_attr = attrs.iter().find(|attr| attr.path.is_ident("displaydoc"));
+
+ if let Some(displaydoc_attr) = displaydoc_attr {
+ let lit = displaydoc_attr
+ .parse_args()
+ .expect("#[displaydoc(\"foo\")] must contain string arguments");
+ let mut display = Display {
+ fmt: lit,
+ args: TokenStream::new(),
+ };
+
+ display.expand_shorthand();
+ return Ok(Some(display));
+ }
+
+ let num_doc_attrs = attrs
+ .iter()
+ .filter(|attr| attr.path.is_ident("doc"))
+ .count();
+
+ if !self.ignore_extra_doc_attributes && num_doc_attrs > 1 {
+ panic!("Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive.");
+ }
+
+ for attr in attrs {
+ if attr.path.is_ident("doc") {
+ let meta = attr.parse_meta()?;
+ let lit = match meta {
+ Meta::NameValue(syn::MetaNameValue {
+ lit: syn::Lit::Str(lit),
+ ..
+ }) => lit,
+ _ => unimplemented!(),
+ };
+
+ // Make an attempt and cleaning up multiline doc comments
+ let doc_str = lit
+ .value()
+ .lines()
+ .map(|line| line.trim().trim_start_matches('*').trim())
+ .collect::<Vec<&str>>()
+ .join("\n");
+
+ let lit = LitStr::new(doc_str.trim(), lit.span());
+
+ let mut display = Display {
+ fmt: lit,
+ args: TokenStream::new(),
+ };
+
+ display.expand_shorthand();
+ return Ok(Some(display));
+ }
+ }
+
+ Ok(None)
+ }
+
+ pub(crate) fn display_with_input(
+ &self,
+ r#enum: &[Attribute],
+ variant: &[Attribute],
+ ) -> Result<Option<VariantDisplay>> {
+ let r#enum = if self.prefix_enum_doc_attributes {
+ let result = self
+ .display(r#enum)?
+ .expect("Missing doc comment on enum with #[prefix_enum_doc_attributes]. Please remove the attribute or add a doc comment to the enum itself.");
+
+ Some(result)
+ } else {
+ None
+ };
+
+ Ok(self
+ .display(variant)?
+ .map(|variant| VariantDisplay { r#enum, variant }))
+ }
+}
diff --git a/third_party/rust/displaydoc/src/expand.rs b/third_party/rust/displaydoc/src/expand.rs
new file mode 100644
index 0000000000..6904cbc8c7
--- /dev/null
+++ b/third_party/rust/displaydoc/src/expand.rs
@@ -0,0 +1,145 @@
+use super::attr::AttrsHelper;
+use proc_macro2::TokenStream;
+use quote::{format_ident, quote};
+use syn::{Data, DataEnum, DataStruct, DeriveInput, Error, Fields, Result};
+
+pub(crate) fn derive(input: &DeriveInput) -> Result<TokenStream> {
+ let impls = match &input.data {
+ Data::Struct(data) => impl_struct(input, data),
+ Data::Enum(data) => impl_enum(input, data),
+ Data::Union(_) => Err(Error::new_spanned(input, "Unions are not supported")),
+ }?;
+
+ let helpers = specialization();
+ let dummy_const = format_ident!("_DERIVE_Display_FOR_{}", input.ident);
+ Ok(quote! {
+ #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
+ const #dummy_const: () = {
+ #helpers
+ #impls
+ };
+ })
+}
+
+#[cfg(feature = "std")]
+fn specialization() -> TokenStream {
+ quote! {
+ trait DisplayToDisplayDoc {
+ fn __displaydoc_display(&self) -> Self;
+ }
+
+ impl<T: core::fmt::Display> DisplayToDisplayDoc for &T {
+ fn __displaydoc_display(&self) -> Self {
+ self
+ }
+ }
+
+ // If the `std` feature gets enabled we want to ensure that any crate
+ // using displaydoc can still reference the std crate, which is already
+ // being compiled in by whoever enabled the `std` feature in
+ // `displaydoc`, even if the crates using displaydoc are no_std.
+ extern crate std;
+
+ trait PathToDisplayDoc {
+ fn __displaydoc_display(&self) -> std::path::Display<'_>;
+ }
+
+ impl PathToDisplayDoc for std::path::Path {
+ fn __displaydoc_display(&self) -> std::path::Display<'_> {
+ self.display()
+ }
+ }
+
+ impl PathToDisplayDoc for std::path::PathBuf {
+ fn __displaydoc_display(&self) -> std::path::Display<'_> {
+ self.display()
+ }
+ }
+ }
+}
+
+#[cfg(not(feature = "std"))]
+fn specialization() -> TokenStream {
+ quote! {}
+}
+
+fn impl_struct(input: &DeriveInput, data: &DataStruct) -> Result<TokenStream> {
+ let ty = &input.ident;
+ let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
+
+ let helper = AttrsHelper::new(&input.attrs);
+
+ let display = helper.display(&input.attrs)?.map(|display| {
+ let pat = match &data.fields {
+ Fields::Named(fields) => {
+ let var = fields.named.iter().map(|field| &field.ident);
+ quote!(Self { #(#var),* })
+ }
+ Fields::Unnamed(fields) => {
+ let var = (0..fields.unnamed.len()).map(|i| format_ident!("_{}", i));
+ quote!(Self(#(#var),*))
+ }
+ Fields::Unit => quote!(_),
+ };
+ quote! {
+ impl #impl_generics core::fmt::Display for #ty #ty_generics #where_clause {
+ fn fmt(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
+ #[allow(unused_variables)]
+ let #pat = self;
+ #display
+ }
+ }
+ }
+ });
+
+ Ok(quote! { #display })
+}
+
+fn impl_enum(input: &DeriveInput, data: &DataEnum) -> Result<TokenStream> {
+ let ty = &input.ident;
+ let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
+
+ let helper = AttrsHelper::new(&input.attrs);
+
+ let displays = data
+ .variants
+ .iter()
+ .map(|variant| helper.display_with_input(&input.attrs, &variant.attrs))
+ .collect::<Result<Vec<_>>>()?;
+
+ if displays.iter().any(Option::is_some) {
+ let arms = data
+ .variants
+ .iter()
+ .zip(displays)
+ .map(|(variant, display)| {
+ let display =
+ display.ok_or_else(|| Error::new_spanned(variant, "missing doc comment"))?;
+ let ident = &variant.ident;
+ Ok(match &variant.fields {
+ Fields::Named(fields) => {
+ let var = fields.named.iter().map(|field| &field.ident);
+ quote!(#ty::#ident { #(#var),* } => { #display })
+ }
+ Fields::Unnamed(fields) => {
+ let var = (0..fields.unnamed.len()).map(|i| format_ident!("_{}", i));
+ quote!(#ty::#ident(#(#var),*) => { #display })
+ }
+ Fields::Unit => quote!(#ty::#ident => { #display }),
+ })
+ })
+ .collect::<Result<Vec<_>>>()?;
+ Ok(quote! {
+ impl #impl_generics core::fmt::Display for #ty #ty_generics #where_clause {
+ fn fmt(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
+ #[allow(unused_variables)]
+ match self {
+ #(#arms,)*
+ }
+ }
+ }
+ })
+ } else {
+ Err(Error::new_spanned(input, "Missing doc comments"))
+ }
+}
diff --git a/third_party/rust/displaydoc/src/fmt.rs b/third_party/rust/displaydoc/src/fmt.rs
new file mode 100644
index 0000000000..5848557ea4
--- /dev/null
+++ b/third_party/rust/displaydoc/src/fmt.rs
@@ -0,0 +1,159 @@
+use crate::attr::Display;
+use proc_macro2::TokenStream;
+use quote::quote_spanned;
+use syn::{Ident, LitStr};
+
+macro_rules! peek_next {
+ ($read:ident) => {
+ match $read.chars().next() {
+ Some(next) => next,
+ None => return,
+ }
+ };
+}
+
+impl Display {
+ // Transform `"error {var}"` to `"error {}", var`.
+ pub(crate) fn expand_shorthand(&mut self) {
+ let span = self.fmt.span();
+ let fmt = self.fmt.value();
+ let mut read = fmt.as_str();
+ let mut out = String::new();
+ let mut args = TokenStream::new();
+
+ while let Some(brace) = read.find('{') {
+ out += &read[..=brace];
+ read = &read[brace + 1..];
+
+ // skip cases where we find a {{
+ if read.starts_with('{') {
+ out.push('{');
+ read = &read[1..];
+ continue;
+ }
+
+ let next = peek_next!(read);
+
+ let var = match next {
+ '0'..='9' => take_int(&mut read),
+ 'a'..='z' | 'A'..='Z' | '_' => take_ident(&mut read),
+ _ => return,
+ };
+
+ let ident = Ident::new(&var, span);
+
+ let next = peek_next!(read);
+
+ let arg = if cfg!(feature = "std") && next == '}' {
+ quote_spanned!(span=> , #ident.__displaydoc_display())
+ } else {
+ quote_spanned!(span=> , #ident)
+ };
+
+ args.extend(arg);
+ }
+
+ out += read;
+ self.fmt = LitStr::new(&out, self.fmt.span());
+ self.args = args;
+ }
+}
+
+fn take_int(read: &mut &str) -> String {
+ let mut int = String::new();
+ int.push('_');
+ for (i, ch) in read.char_indices() {
+ match ch {
+ '0'..='9' => int.push(ch),
+ _ => {
+ *read = &read[i..];
+ break;
+ }
+ }
+ }
+ int
+}
+
+fn take_ident(read: &mut &str) -> String {
+ let mut ident = String::new();
+ for (i, ch) in read.char_indices() {
+ match ch {
+ 'a'..='z' | 'A'..='Z' | '0'..='9' | '_' => ident.push(ch),
+ _ => {
+ *read = &read[i..];
+ break;
+ }
+ }
+ }
+ ident
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use pretty_assertions::assert_eq;
+ use proc_macro2::Span;
+
+ fn assert(input: &str, fmt: &str, args: &str) {
+ let mut display = Display {
+ fmt: LitStr::new(input, Span::call_site()),
+ args: TokenStream::new(),
+ };
+ display.expand_shorthand();
+ assert_eq!(fmt, display.fmt.value());
+ assert_eq!(args, display.args.to_string());
+ }
+
+ #[test]
+ fn test_expand() {
+ assert("fn main() {{ }}", "fn main() {{ }}", "");
+ }
+
+ #[test]
+ #[cfg_attr(not(feature = "std"), ignore)]
+ fn test_std_expand() {
+ assert(
+ "{v} {v:?} {0} {0:?}",
+ "{} {:?} {} {:?}",
+ ", v . __displaydoc_display () , v , _0 . __displaydoc_display () , _0",
+ );
+ assert("error {var}", "error {}", ", var . __displaydoc_display ()");
+
+ assert(
+ "error {var1}",
+ "error {}",
+ ", var1 . __displaydoc_display ()",
+ );
+
+ assert(
+ "error {var1var}",
+ "error {}",
+ ", var1var . __displaydoc_display ()",
+ );
+
+ assert(
+ "The path {0}",
+ "The path {}",
+ ", _0 . __displaydoc_display ()",
+ );
+ assert("The path {0:?}", "The path {:?}", ", _0");
+ }
+
+ #[test]
+ #[cfg_attr(feature = "std", ignore)]
+ fn test_nostd_expand() {
+ assert(
+ "{v} {v:?} {0} {0:?}",
+ "{} {:?} {} {:?}",
+ ", v , v , _0 , _0",
+ );
+ assert("error {var}", "error {}", ", var");
+
+ assert("The path {0}", "The path {}", ", _0");
+ assert("The path {0:?}", "The path {:?}", ", _0");
+
+ assert("error {var1}", "error {}", ", var1");
+
+ assert("error {var1var}", "error {}", ", var1var");
+ }
+}
diff --git a/third_party/rust/displaydoc/src/lib.rs b/third_party/rust/displaydoc/src/lib.rs
new file mode 100644
index 0000000000..083c613845
--- /dev/null
+++ b/third_party/rust/displaydoc/src/lib.rs
@@ -0,0 +1,122 @@
+//! This library provides a convenient derive macro for the standard library's
+//! [`core::fmt::Display`] trait.
+//!
+//! [`core::fmt::Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html
+//!
+//! ```toml
+//! [dependencies]
+//! displaydoc = "0.2"
+//! ```
+//!
+//! *Compiler support: requires rustc 1.31+*
+//!
+//! <br>
+//!
+//! ## Example
+//!
+//! ```rust
+//! use std::io;
+//! use displaydoc::Display;
+//! use thiserror::Error;
+//!
+//! #[derive(Display, Error, Debug)]
+//! pub enum DataStoreError {
+//! /// data store disconnected
+//! Disconnect(#[source] io::Error),
+//! /// the data for key `{0}` is not available
+//! Redaction(String),
+//! /// invalid header (expected {expected:?}, found {found:?})
+//! InvalidHeader {
+//! expected: String,
+//! found: String,
+//! },
+//! /// unknown data store error
+//! Unknown,
+//! }
+//! ```
+//!
+//! <br>
+//!
+//! ## Details
+//!
+//! - A `Display` impl is generated for your type if you provide doc comment
+//! messages on the struct or each variant of your enum, as shown above in the
+//! example.
+//!
+//! The messages support a shorthand for interpolating fields from the error.
+//!
+//! - `/// {var}` ⟶ `write!("{}", self.var)`
+//! - `/// {0}` ⟶ `write!("{}", self.0)`
+//! - `/// {var:?}` ⟶ `write!("{:?}", self.var)`
+//! - `/// {0:?}` ⟶ `write!("{:?}", self.0)`
+//!
+//! - Two optional attributes can be added to your types next to the derive:
+//!
+//! - `#[ignore_extra_doc_attributes]` makes the macro ignore any doc
+//! comment attributes (or `///` lines) after the first. Multi-line
+//! comments using `///` are otherwise treated as an error, so use this
+//! attribute or consider switching to block doc comments (`/** */`).
+//!
+//! - `#[prefix_enum_doc_attributes]` combines the doc comment message on
+//! your enum itself with the messages for each variant, in the format
+//! “enum: variant”. When added to an enum, the doc comment on the enum
+//! becomes mandatory. When added to any other type, it has no effect.
+//!
+//! - In case you want to have an independent doc comment, the
+//! `#[displaydoc("...")` atrribute may be used on the variant or struct to
+//! override it.
+//!
+//! <br>
+//!
+//! ## FAQ
+//!
+//! 1. **Is this crate `no_std` compatible?**
+//! * Yes! This crate implements the `core::fmt::Display` trait not the `std::fmt::Display` trait so it should work in `std` and `no_std` environments. Just add `default-features = false`.
+//!
+//! 2. **Does this crate work with `Path` and `PathBuf` via the `Display` trait?**
+//! * Yuuup. This crate uses @dtolnay's [autoref specialization technique](https://github.com/dtolnay/case-studies/blob/master/autoref-specialization/README.md) to add a special trait for types to get the display impl, it then specializes for `Path` and `PathBuf` and when either of these types are found it calls `self.display()` to get a `std::path::Display<'_>` type which can be used with the Display format specifier!
+#![doc(html_root_url = "https://docs.rs/displaydoc/0.2.3")]
+#![cfg_attr(docsrs, feature(doc_cfg))]
+#![warn(
+ rust_2018_idioms,
+ unreachable_pub,
+ bad_style,
+ const_err,
+ dead_code,
+ improper_ctypes,
+ non_shorthand_field_patterns,
+ no_mangle_generic_items,
+ overflowing_literals,
+ path_statements,
+ patterns_in_fns_without_body,
+ private_in_public,
+ unconditional_recursion,
+ unused,
+ unused_allocation,
+ unused_comparisons,
+ unused_parens,
+ while_true
+)]
+#![allow(clippy::try_err)]
+
+#[allow(unused_extern_crates)]
+extern crate proc_macro;
+
+mod attr;
+mod expand;
+mod fmt;
+
+use proc_macro::TokenStream;
+use syn::{parse_macro_input, DeriveInput};
+
+/// Derive macro for implementing `Display` via doc comment attributes
+#[proc_macro_derive(
+ Display,
+ attributes(ignore_extra_doc_attributes, prefix_enum_doc_attributes, displaydoc)
+)]
+pub fn derive_error(input: TokenStream) -> TokenStream {
+ let input = parse_macro_input!(input as DeriveInput);
+ expand::derive(&input)
+ .unwrap_or_else(|err| err.to_compile_error())
+ .into()
+}
diff --git a/third_party/rust/displaydoc/tests/compile_tests.rs b/third_party/rust/displaydoc/tests/compile_tests.rs
new file mode 100644
index 0000000000..29c72a8621
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/compile_tests.rs
@@ -0,0 +1,29 @@
+#[allow(unused_attributes)]
+#[rustversion::attr(not(nightly), ignore)]
+#[test]
+fn no_std() {
+ let t = trybuild::TestCases::new();
+ #[cfg(not(feature = "std"))]
+ t.compile_fail("tests/no_std/without.rs");
+ #[cfg(not(feature = "std"))]
+ t.compile_fail("tests/no_std/multi_line.rs");
+ #[cfg(not(feature = "std"))]
+ t.pass("tests/no_std/multi_line_allow.rs");
+ #[cfg(not(feature = "std"))]
+ t.compile_fail("tests/no_std/enum_prefix_missing.rs");
+ #[cfg(not(feature = "std"))]
+ t.pass("tests/no_std/enum_prefix.rs");
+ #[cfg(feature = "std")]
+ t.compile_fail("tests/std/without.rs");
+ #[cfg(feature = "std")]
+ t.compile_fail("tests/std/multi_line.rs");
+ #[cfg(feature = "std")]
+ t.pass("tests/std/multi_line_allow.rs");
+ #[cfg(feature = "std")]
+ t.compile_fail("tests/std/enum_prefix_missing.rs");
+ #[cfg(feature = "std")]
+ t.pass("tests/std/enum_prefix.rs");
+ #[cfg(feature = "std")]
+ t.pass("tests/std/multiple.rs");
+ t.pass("tests/no_std/with.rs");
+}
diff --git a/third_party/rust/displaydoc/tests/happy.rs b/third_party/rust/displaydoc/tests/happy.rs
new file mode 100644
index 0000000000..85aa78f137
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/happy.rs
@@ -0,0 +1,152 @@
+use displaydoc::Display;
+
+#[cfg(feature = "std")]
+use std::path::PathBuf;
+
+#[derive(Display)]
+/// Just a basic struct {thing}
+struct HappyStruct {
+ thing: &'static str,
+}
+
+#[derive(Display)]
+#[ignore_extra_doc_attributes]
+/// Just a basic struct {thing}
+/// and this line should get ignored
+struct HappyStruct2 {
+ thing: &'static str,
+}
+
+#[derive(Display)]
+enum Happy {
+ /// I really like Variant1
+ Variant1,
+ /// Variant2 is pretty swell 2
+ Variant2,
+ /// Variant3 is okay {sometimes}
+ Variant3 { sometimes: &'static str },
+ /**
+ * Variant4 wants to have a lot of lines
+ *
+ * Lets see how this works out for it
+ */
+ Variant4,
+ /// Variant5 has a parameter {0} and some regular comments
+ // A regular comment that won't get picked
+ Variant5(u32),
+
+ /// The path {0}
+ #[cfg(feature = "std")]
+ Variant6(PathBuf),
+
+ /// These docs are ignored
+ #[displaydoc("Variant7 has a parameter {0} and uses #[displaydoc]")]
+ /// These docs are also ignored
+ Variant7(u32),
+}
+
+// Used for testing indented doc comments
+mod inner_mod {
+ use super::Display;
+
+ #[derive(Display)]
+ pub enum InnerHappy {
+ /// I really like Variant1
+ Variant1,
+ /// Variant2 is pretty swell 2
+ Variant2,
+ /// Variant3 is okay {sometimes}
+ Variant3 { sometimes: &'static str },
+ /**
+ * Variant4 wants to have a lot of lines
+ *
+ * Lets see how this works out for it
+ */
+ Variant4,
+ /// Variant5 has a parameter {0} and some regular comments
+ // A regular comment that won't get picked
+ Variant5(u32),
+
+ /** what happens if we
+ * put text on the first line?
+ */
+ Variant6,
+
+ /**
+ what happens if we don't use *?
+ */
+ Variant7,
+
+ /**
+ *
+ * what about extra new lines?
+ */
+ Variant8,
+ }
+}
+
+fn assert_display<T: std::fmt::Display>(input: T, expected: &'static str) {
+ let out = format!("{}", input);
+ assert_eq!(expected, out);
+}
+
+#[test]
+fn does_it_print() {
+ assert_display(Happy::Variant1, "I really like Variant1");
+ assert_display(Happy::Variant2, "Variant2 is pretty swell 2");
+ assert_display(Happy::Variant3 { sometimes: "hi" }, "Variant3 is okay hi");
+ assert_display(
+ Happy::Variant4,
+ "Variant4 wants to have a lot of lines\n\nLets see how this works out for it",
+ );
+ assert_display(
+ Happy::Variant5(2),
+ "Variant5 has a parameter 2 and some regular comments",
+ );
+ assert_display(
+ Happy::Variant7(2),
+ "Variant7 has a parameter 2 and uses #[displaydoc]",
+ );
+ assert_display(HappyStruct { thing: "hi" }, "Just a basic struct hi");
+
+ assert_display(HappyStruct2 { thing: "hi2" }, "Just a basic struct hi2");
+
+ assert_display(inner_mod::InnerHappy::Variant1, "I really like Variant1");
+ assert_display(
+ inner_mod::InnerHappy::Variant2,
+ "Variant2 is pretty swell 2",
+ );
+ assert_display(
+ inner_mod::InnerHappy::Variant3 { sometimes: "hi" },
+ "Variant3 is okay hi",
+ );
+ assert_display(
+ inner_mod::InnerHappy::Variant4,
+ "Variant4 wants to have a lot of lines\n\nLets see how this works out for it",
+ );
+ assert_display(
+ inner_mod::InnerHappy::Variant5(2),
+ "Variant5 has a parameter 2 and some regular comments",
+ );
+ assert_display(
+ inner_mod::InnerHappy::Variant6,
+ "what happens if we\nput text on the first line?",
+ );
+ assert_display(
+ inner_mod::InnerHappy::Variant7,
+ "what happens if we don\'t use *?",
+ );
+ assert_display(
+ inner_mod::InnerHappy::Variant8,
+ "what about extra new lines?",
+ );
+}
+
+#[test]
+#[cfg(feature = "std")]
+fn does_it_print_path() {
+ assert_display(
+ Happy::Variant6(PathBuf::from("/var/log/happy")),
+ "The path /var/log/happy",
+ );
+}
diff --git a/third_party/rust/displaydoc/tests/no_std/enum_prefix.rs b/third_party/rust/displaydoc/tests/no_std/enum_prefix.rs
new file mode 100644
index 0000000000..1c5479118b
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/no_std/enum_prefix.rs
@@ -0,0 +1,36 @@
+#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg_attr(not(feature = "std"), start)]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+use displaydoc::Display;
+
+/// this type is pretty swell
+#[derive(Display)]
+#[prefix_enum_doc_attributes]
+enum TestType {
+ /// this variant is too
+ Variant1,
+
+ /// this variant is two
+ Variant2,
+}
+
+static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+
+#[cfg(feature = "std")]
+fn main() {}
diff --git a/third_party/rust/displaydoc/tests/no_std/enum_prefix_missing.rs b/third_party/rust/displaydoc/tests/no_std/enum_prefix_missing.rs
new file mode 100644
index 0000000000..5cd9e6df82
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/no_std/enum_prefix_missing.rs
@@ -0,0 +1,35 @@
+#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg_attr(not(feature = "std"), start)]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+use displaydoc::Display;
+
+#[derive(Display)]
+#[prefix_enum_doc_attributes]
+enum TestType {
+ /// this variant is too
+ Variant1,
+
+ /// this variant is two
+ Variant2,
+}
+
+static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+
+#[cfg(feature = "std")]
+fn main() {}
diff --git a/third_party/rust/displaydoc/tests/no_std/enum_prefix_missing.stderr b/third_party/rust/displaydoc/tests/no_std/enum_prefix_missing.stderr
new file mode 100644
index 0000000000..a0db216945
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/no_std/enum_prefix_missing.stderr
@@ -0,0 +1,19 @@
+error: proc-macro derive panicked
+ --> $DIR/enum_prefix_missing.rs:22:10
+ |
+22 | #[derive(Display)]
+ | ^^^^^^^
+ |
+ = help: message: Missing doc comment on enum with #[prefix_enum_doc_attributes]. Please remove the attribute or add a doc comment to the enum itself.
+
+error[E0277]: `TestType` doesn't implement `Display`
+ --> $DIR/enum_prefix_missing.rs:32:44
+ |
+32 | static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+ | -------------------------------------------^^^^^^^^----------------------
+ | | |
+ | | `TestType` cannot be formatted with the default formatter
+ | required by this bound in `assert_impl_all`
+ |
+ = help: the trait `Display` is not implemented for `TestType`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
diff --git a/third_party/rust/displaydoc/tests/no_std/multi_line.rs b/third_party/rust/displaydoc/tests/no_std/multi_line.rs
new file mode 100644
index 0000000000..cadb83e705
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/no_std/multi_line.rs
@@ -0,0 +1,37 @@
+#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg_attr(not(feature = "std"), start)]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+use displaydoc::Display;
+
+/// this type is pretty swell
+#[derive(Display)]
+enum TestType {
+ /// This one is okay
+ Variant1,
+
+ /// Multi
+ /// line
+ /// doc.
+ Variant2,
+}
+
+static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+
+#[cfg(feature = "std")]
+fn main() {}
diff --git a/third_party/rust/displaydoc/tests/no_std/multi_line.stderr b/third_party/rust/displaydoc/tests/no_std/multi_line.stderr
new file mode 100644
index 0000000000..e23d134c86
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/no_std/multi_line.stderr
@@ -0,0 +1,19 @@
+error: proc-macro derive panicked
+ --> $DIR/multi_line.rs:23:10
+ |
+23 | #[derive(Display)]
+ | ^^^^^^^
+ |
+ = help: message: Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive.
+
+error[E0277]: `TestType` doesn't implement `Display`
+ --> $DIR/multi_line.rs:34:44
+ |
+34 | static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+ | -------------------------------------------^^^^^^^^----------------------
+ | | |
+ | | `TestType` cannot be formatted with the default formatter
+ | required by this bound in `assert_impl_all`
+ |
+ = help: the trait `Display` is not implemented for `TestType`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
diff --git a/third_party/rust/displaydoc/tests/no_std/multi_line_allow.rs b/third_party/rust/displaydoc/tests/no_std/multi_line_allow.rs
new file mode 100644
index 0000000000..05bdcf9fb8
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/no_std/multi_line_allow.rs
@@ -0,0 +1,38 @@
+#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg_attr(not(feature = "std"), start)]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+use displaydoc::Display;
+
+/// this type is pretty swell
+#[derive(Display)]
+#[ignore_extra_doc_attributes]
+enum TestType {
+ /// This one is okay
+ Variant1,
+
+ /// Multi
+ /// line
+ /// doc.
+ Variant2,
+}
+
+static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+
+#[cfg(feature = "std")]
+fn main() {}
diff --git a/third_party/rust/displaydoc/tests/no_std/with.rs b/third_party/rust/displaydoc/tests/no_std/with.rs
new file mode 100644
index 0000000000..7de3da67f1
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/no_std/with.rs
@@ -0,0 +1,32 @@
+#![feature(lang_items, start)]
+#![no_std]
+
+#[start]
+#[cfg(not(feature = "std"))]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+#[cfg(feature = "std")]
+fn main() {}
+
+use displaydoc::Display;
+
+/// this type is pretty swell
+#[derive(Display)]
+struct FakeType;
+
+static_assertions::assert_impl_all!(label; FakeType, core::fmt::Display);
diff --git a/third_party/rust/displaydoc/tests/no_std/without.rs b/third_party/rust/displaydoc/tests/no_std/without.rs
new file mode 100644
index 0000000000..32905aad96
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/no_std/without.rs
@@ -0,0 +1,28 @@
+#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg_attr(not(feature = "std"), start)]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+use displaydoc::Display;
+
+/// this type is pretty swell
+struct FakeType;
+
+static_assertions::assert_impl_all!(label; FakeType, core::fmt::Display);
+
+#[cfg(feature = "std")]
+fn main() {}
diff --git a/third_party/rust/displaydoc/tests/no_std/without.stderr b/third_party/rust/displaydoc/tests/no_std/without.stderr
new file mode 100644
index 0000000000..81de13b74d
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/no_std/without.stderr
@@ -0,0 +1,19 @@
+warning: unused import: `displaydoc::Display`
+ --> $DIR/without.rs:20:5
+ |
+20 | use displaydoc::Display;
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(unused_imports)]` on by default
+
+error[E0277]: `FakeType` doesn't implement `Display`
+ --> $DIR/without.rs:25:44
+ |
+25 | static_assertions::assert_impl_all!(label; FakeType, core::fmt::Display);
+ | -------------------------------------------^^^^^^^^----------------------
+ | | |
+ | | `FakeType` cannot be formatted with the default formatter
+ | required by this bound in `assert_impl_all`
+ |
+ = help: the trait `Display` is not implemented for `FakeType`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
diff --git a/third_party/rust/displaydoc/tests/num_in_field.rs b/third_party/rust/displaydoc/tests/num_in_field.rs
new file mode 100644
index 0000000000..9510f8206b
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/num_in_field.rs
@@ -0,0 +1,22 @@
+/// {foo1} {foo2}
+#[derive(displaydoc::Display)]
+pub struct Test {
+ foo1: String,
+ foo2: String,
+}
+
+fn assert_display<T: std::fmt::Display>(input: T, expected: &'static str) {
+ let out = format!("{}", input);
+ assert_eq!(expected, out);
+}
+
+#[test]
+fn does_it_print() {
+ assert_display(
+ Test {
+ foo1: "hi".into(),
+ foo2: "hello".into(),
+ },
+ "hi hello",
+ );
+}
diff --git a/third_party/rust/displaydoc/tests/std/enum_prefix.rs b/third_party/rust/displaydoc/tests/std/enum_prefix.rs
new file mode 100644
index 0000000000..1c5479118b
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/std/enum_prefix.rs
@@ -0,0 +1,36 @@
+#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg_attr(not(feature = "std"), start)]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+use displaydoc::Display;
+
+/// this type is pretty swell
+#[derive(Display)]
+#[prefix_enum_doc_attributes]
+enum TestType {
+ /// this variant is too
+ Variant1,
+
+ /// this variant is two
+ Variant2,
+}
+
+static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+
+#[cfg(feature = "std")]
+fn main() {}
diff --git a/third_party/rust/displaydoc/tests/std/enum_prefix_missing.rs b/third_party/rust/displaydoc/tests/std/enum_prefix_missing.rs
new file mode 100644
index 0000000000..5cd9e6df82
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/std/enum_prefix_missing.rs
@@ -0,0 +1,35 @@
+#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg_attr(not(feature = "std"), start)]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+use displaydoc::Display;
+
+#[derive(Display)]
+#[prefix_enum_doc_attributes]
+enum TestType {
+ /// this variant is too
+ Variant1,
+
+ /// this variant is two
+ Variant2,
+}
+
+static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+
+#[cfg(feature = "std")]
+fn main() {}
diff --git a/third_party/rust/displaydoc/tests/std/enum_prefix_missing.stderr b/third_party/rust/displaydoc/tests/std/enum_prefix_missing.stderr
new file mode 100644
index 0000000000..7f60f1bf58
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/std/enum_prefix_missing.stderr
@@ -0,0 +1,19 @@
+error: proc-macro derive panicked
+ --> $DIR/enum_prefix_missing.rs:22:10
+ |
+22 | #[derive(Display)]
+ | ^^^^^^^
+ |
+ = help: message: Missing doc comment on enum with #[prefix_enum_doc_attributes]. Please remove the attribute or add a doc comment to the enum itself.
+
+error[E0277]: `TestType` doesn't implement `std::fmt::Display`
+ --> $DIR/enum_prefix_missing.rs:32:44
+ |
+32 | static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+ | -------------------------------------------^^^^^^^^----------------------
+ | | |
+ | | `TestType` cannot be formatted with the default formatter
+ | required by this bound in `assert_impl_all`
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `TestType`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
diff --git a/third_party/rust/displaydoc/tests/std/multi_line.rs b/third_party/rust/displaydoc/tests/std/multi_line.rs
new file mode 100644
index 0000000000..cadb83e705
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/std/multi_line.rs
@@ -0,0 +1,37 @@
+#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg_attr(not(feature = "std"), start)]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+use displaydoc::Display;
+
+/// this type is pretty swell
+#[derive(Display)]
+enum TestType {
+ /// This one is okay
+ Variant1,
+
+ /// Multi
+ /// line
+ /// doc.
+ Variant2,
+}
+
+static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+
+#[cfg(feature = "std")]
+fn main() {}
diff --git a/third_party/rust/displaydoc/tests/std/multi_line.stderr b/third_party/rust/displaydoc/tests/std/multi_line.stderr
new file mode 100644
index 0000000000..5e41e5428e
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/std/multi_line.stderr
@@ -0,0 +1,19 @@
+error: proc-macro derive panicked
+ --> $DIR/multi_line.rs:23:10
+ |
+23 | #[derive(Display)]
+ | ^^^^^^^
+ |
+ = help: message: Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive.
+
+error[E0277]: `TestType` doesn't implement `std::fmt::Display`
+ --> $DIR/multi_line.rs:34:44
+ |
+34 | static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+ | -------------------------------------------^^^^^^^^----------------------
+ | | |
+ | | `TestType` cannot be formatted with the default formatter
+ | required by this bound in `assert_impl_all`
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `TestType`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
diff --git a/third_party/rust/displaydoc/tests/std/multi_line_allow.rs b/third_party/rust/displaydoc/tests/std/multi_line_allow.rs
new file mode 100644
index 0000000000..05bdcf9fb8
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/std/multi_line_allow.rs
@@ -0,0 +1,38 @@
+#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg_attr(not(feature = "std"), start)]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+use displaydoc::Display;
+
+/// this type is pretty swell
+#[derive(Display)]
+#[ignore_extra_doc_attributes]
+enum TestType {
+ /// This one is okay
+ Variant1,
+
+ /// Multi
+ /// line
+ /// doc.
+ Variant2,
+}
+
+static_assertions::assert_impl_all!(label; TestType, core::fmt::Display);
+
+#[cfg(feature = "std")]
+fn main() {}
diff --git a/third_party/rust/displaydoc/tests/std/multiple.rs b/third_party/rust/displaydoc/tests/std/multiple.rs
new file mode 100644
index 0000000000..915f9abdda
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/std/multiple.rs
@@ -0,0 +1,38 @@
+#![feature(lang_items, start)]
+#![no_std]
+
+#[start]
+#[cfg(not(feature = "std"))]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+#[cfg(feature = "std")]
+fn main() {}
+
+use displaydoc::Display;
+
+/// this type is pretty swell
+#[derive(Display)]
+struct FakeType;
+
+static_assertions::assert_impl_all!(label; FakeType, core::fmt::Display);
+
+/// this type is pretty swell2
+#[derive(Display)]
+struct FakeType2;
+
+static_assertions::assert_impl_all!(label2; FakeType2, core::fmt::Display);
diff --git a/third_party/rust/displaydoc/tests/std/without.rs b/third_party/rust/displaydoc/tests/std/without.rs
new file mode 100644
index 0000000000..32905aad96
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/std/without.rs
@@ -0,0 +1,28 @@
+#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg_attr(not(feature = "std"), start)]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+ 0
+}
+#[lang = "eh_personality"]
+#[no_mangle]
+#[cfg(not(feature = "std"))]
+pub extern "C" fn rust_eh_personality() {}
+#[panic_handler]
+#[cfg(not(feature = "std"))]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ libc::abort();
+ }
+}
+
+use displaydoc::Display;
+
+/// this type is pretty swell
+struct FakeType;
+
+static_assertions::assert_impl_all!(label; FakeType, core::fmt::Display);
+
+#[cfg(feature = "std")]
+fn main() {}
diff --git a/third_party/rust/displaydoc/tests/std/without.stderr b/third_party/rust/displaydoc/tests/std/without.stderr
new file mode 100644
index 0000000000..9780427e8f
--- /dev/null
+++ b/third_party/rust/displaydoc/tests/std/without.stderr
@@ -0,0 +1,19 @@
+warning: unused import: `displaydoc::Display`
+ --> $DIR/without.rs:20:5
+ |
+20 | use displaydoc::Display;
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(unused_imports)]` on by default
+
+error[E0277]: `FakeType` doesn't implement `std::fmt::Display`
+ --> $DIR/without.rs:25:44
+ |
+25 | static_assertions::assert_impl_all!(label; FakeType, core::fmt::Display);
+ | -------------------------------------------^^^^^^^^----------------------
+ | | |
+ | | `FakeType` cannot be formatted with the default formatter
+ | required by this bound in `assert_impl_all`
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `FakeType`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead