From f979b8f47eb25d48322d8135dca54c40200221c7 Mon Sep 17 00:00:00 2001 From: Serhii Plyhun Date: Mon, 19 Mar 2018 09:26:10 +0100 Subject: [PATCH 1/7] rustc-serialize version update --- Cargo.lock | 70 ++++++++++++++++++++++++++++++++++-------------------- Cargo.toml | 4 ++-- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a7dedd..fe36430 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,17 +1,13 @@ -[root] -name = "rainicorn" -version = "2.0.0" -dependencies = [ - "rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_errors 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "cfg-if" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -23,17 +19,37 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.14" +version = "0.2.39" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "log" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "log" -version = "0.3.6" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rainicorn" +version = "2.0.0" +dependencies = [ + "rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "rustc-serialize" -version = "0.3.19" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -46,11 +62,11 @@ name = "syntex_errors" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -59,7 +75,7 @@ name = "syntex_pos" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -68,18 +84,18 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_errors 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "term" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -103,15 +119,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "39dfaaa0f4da0f1a06876c5d94329d739ad0150868069cc235f1ddf80a0480e7" -"checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" -"checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b" +"checksum libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "f54263ad99207254cf58b5f701ecb432c717445ea2ee8af387334bdd1a03fdff" +"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" +"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" +"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7cfffa8a89d8758be2dd5605c5fc62bce055af2491ebf3ce953d4d31512c59fd" "checksum syntex_errors 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2784ff2ca385a451f1f835dcb3926e5c61461c6468aac1e35edcbc4cd33808" "checksum syntex_pos 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25fadff25e4db9336cd715dea4bc7d4bf51d08cc39a1463b689661f1dea6893c" "checksum syntex_syntax 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3c7d1082d30f7042d1e7b00bd2ab0466daa84529fa13891e9312d8a32fd97e" -"checksum term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3deff8a2b3b6607d6d7cc32ac25c0b33709453ca9cceac006caac51e963cf94a" +"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" "checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml index e36c4f2..c044512 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ name = "rainicorn" version = "2.0.0" [dependencies] -syntex_errors = "0.48.0" -syntex_syntax = "0.48.0" +syntex_errors = "^0.48" +syntex_syntax = "^0.48" rustdt_util ="0.2.3" [[bin]] From 95a64121640bb753b3b0b37cb129bc79727174eb Mon Sep 17 00:00:00 2001 From: Serhii Plyhun Date: Thu, 19 Jul 2018 15:15:46 +0200 Subject: [PATCH 2/7] Freshen the parser, rustfmt --- Cargo.lock | 238 +++++-- Cargo.toml | 34 +- rustfmt.toml | 1 + src/lib.rs | 21 +- src/main.rs | 32 +- src/parse_describe.rs | 878 +++++++++++++------------- src/source_model.rs | 256 ++++---- src/structure_visitor.rs | 1279 ++++++++++++++++++-------------------- src/token_writer.rs | 246 ++++---- 9 files changed, 1520 insertions(+), 1465 deletions(-) create mode 100644 rustfmt.toml diff --git a/Cargo.lock b/Cargo.lock index fe36430..8475a7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,11 +1,52 @@ [[package]] name = "bitflags" -version = "0.7.0" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bitflags" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.2" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "dtoa" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "extprim" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "itoa" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -19,7 +60,7 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.39" +version = "0.2.42" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -27,15 +68,36 @@ name = "log" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.4.1" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "proc-macro2" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -43,54 +105,120 @@ name = "rainicorn" version = "2.0.0" dependencies = [ "rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_errors 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rustc-serialize" -version = "0.3.24" +name = "rand" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_version" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "rustdt_util" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_json" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syntex_errors" -version = "0.48.0" +version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_pos 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syntex_pos" -version = "0.48.0" +version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syntex_syntax" -version = "0.48.0" +version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "extprim 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_errors 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_pos 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -104,7 +232,7 @@ dependencies = [ [[package]] name = "unicode-xid" -version = "0.0.3" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -112,24 +240,62 @@ name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winapi" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [metadata] -"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" +"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" +"checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" +"checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" +"checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" +"checksum extprim 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "054bc2552b3f66fa8097e29e47255bfff583c08e737a67cbbb54b817ddaa5206" +"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "f54263ad99207254cf58b5f701ecb432c717445ea2ee8af387334bdd1a03fdff" +"checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" -"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" +"checksum log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "61bd98ae7f7b754bc53dca7d44b604f733c6bba044ea6f41bc8d89272d8161d2" +"checksum num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "630de1ef5cc79d0cdd78b7e33b81f083cbfe90de0f4b2b2f07f905867c70e9fe" +"checksum proc-macro2 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c65b1ea15bb859d922cade2d1765b4b88beac339cbfad545ef2d2ef8c8215ee6" +"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" +"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" +"checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" "checksum rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7cfffa8a89d8758be2dd5605c5fc62bce055af2491ebf3ce953d4d31512c59fd" -"checksum syntex_errors 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2784ff2ca385a451f1f835dcb3926e5c61461c6468aac1e35edcbc4cd33808" -"checksum syntex_pos 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25fadff25e4db9336cd715dea4bc7d4bf51d08cc39a1463b689661f1dea6893c" -"checksum syntex_syntax 0.48.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3c7d1082d30f7042d1e7b00bd2ab0466daa84529fa13891e9312d8a32fd97e" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +"checksum serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3adf19c07af6d186d91dae8927b83b0553d07ca56cbf7f2f32560455c91920" +"checksum serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "3525a779832b08693031b8ecfb0de81cd71cfd3812088fafe9a7496789572124" +"checksum serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c6908c7b925cd6c590358a4034de93dbddb20c45e1d021931459fd419bf0e2" +"checksum syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2beff8ebc3658f07512a413866875adddd20f4fd47b2a4e6c9da65cd281baaea" +"checksum syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3133289179676c9f5c5b2845bf5a2e127769f4889fcbada43035ef6bd662605e" +"checksum syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "30ab669fa003d208c681f874bbc76d91cc3d32550d16b5d9d2087cf477316470" +"checksum syntex_syntax 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03815b9f04d95828770d9c974aa39c6e1f6ef3114eb77a3ce09008a0d15dd142" "checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" -"checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index c044512..82ee0ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,18 @@ -[package] -name = "rainicorn" -version = "2.0.0" - -[dependencies] -syntex_errors = "^0.48" -syntex_syntax = "^0.48" -rustdt_util ="0.2.3" - -[[bin]] -name = "parse_describe" -test = false - -[lib] -name = "rainicorn" -path = "src/lib.rs" +[package] +name = "rainicorn" +version = "2.0.0" +autobins = false + +[dependencies] +syntex_errors = "^0.59" +syntex_syntax = "^0.59" +rustdt_util ="0.2.3" + +[[bin]] +name = "parse_describe" +path = "src/main.rs" +test = false + +[lib] +name = "rainicorn" +path = "src/lib.rs" diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..34eb15b --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +max_width = 250 diff --git a/src/lib.rs b/src/lib.rs index dc6bc9e..486480a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,10 @@ -#![allow(non_snake_case)] - -extern crate syntex_syntax; -extern crate syntex_errors; -extern crate rustdt_util as util; - -pub mod token_writer; -pub mod source_model; -pub mod parse_describe; -pub mod structure_visitor; - +#![allow(non_snake_case)] + +extern crate rustdt_util as util; +extern crate syntex_errors; +extern crate syntex_syntax; + +pub mod parse_describe; +pub mod source_model; +pub mod structure_visitor; +pub mod token_writer; diff --git a/src/main.rs b/src/main.rs index 40297c7..8cd00ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,15 @@ -extern crate rainicorn; - -use rainicorn::*; - -use std::io::{self, Read}; - -fn main() { - - let mut buffer = String::new(); - let result = io::stdin().read_to_string(&mut buffer); - - match result { - Err(err) => println!("Error: {}.", err), - Ok(_) => parse_describe::parse_analysis_for_Stdout(&buffer), - } - -} \ No newline at end of file +extern crate rainicorn; + +use rainicorn::*; + +use std::io::{self, Read}; + +fn main() { + let mut buffer = String::new(); + let result = io::stdin().read_to_string(&mut buffer); + + match result { + Err(err) => println!("Error: {}.", err), + Ok(_) => parse_describe::parse_analysis_for_Stdout(&buffer), + } +} diff --git a/src/parse_describe.rs b/src/parse_describe.rs index 338b6f9..e099f4c 100644 --- a/src/parse_describe.rs +++ b/src/parse_describe.rs @@ -1,463 +1,415 @@ -// Copyright 2015 Bruno Medeiros -// -// 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. - -use util::core::*; -use util::string::*; -use source_model::*; - -use syntex_syntax::syntax::ast; -use syntex_syntax::parse::{ self, ParseSess }; -use syntex_syntax::visit; -use syntex_syntax::codemap::{ self, MultiSpan, CodeMap}; -use syntex_errors::{ Handler, Level, DiagnosticBuilder }; -use syntex_errors::emitter::{ self }; - - -use std::boxed::Box; -use std::path::Path; - -use token_writer::TokenWriter; - -use std::cell::RefCell; -use std::rc::*; -use std::io; -use std::io::Write; -use std::fmt; -use std::path::PathBuf; -use std::env; - - -/* ----------------- ----------------- */ - -pub fn parse_analysis_for_Stdout(source : &str) { - parse_analysis(source, StdoutWrite(io::stdout())).ok(); - println!(""); - io::stdout().flush().ok(); -} - -pub fn parse_analysis(source : &str, out : T) -> GResult { - let (messages, elements) = parse_crate_with_messages(source); - - let outRc = Rc::new(RefCell::new(out)); - try!(write_parse_analysis_do(messages, elements, outRc.clone())); - let res = unwrap_Rc_RefCell(outRc); - return Ok(res); -} - -use std::thread; -use std::sync::{Arc, Mutex}; - -pub fn parse_crate_with_messages(source: &str) -> (Vec, Vec) { - - let messages = Arc::new(Mutex::new(vec![])); - let elements = - { - let source = String::from(source); - let messages = messages.clone(); - - let worker_thread = thread::Builder::new().name("parser_thread".to_string()).spawn(move || { - parse_crate_with_messages_do(&source, messages) - }).unwrap(); - - worker_thread.join().unwrap_or(vec![]) - }; - - let messages : Mutex> = Arc::try_unwrap(messages).ok().unwrap(); - let messages : Vec = messages.into_inner().unwrap(); - - return (messages, elements); -} - -pub fn parse_crate_with_messages_do(source: &str, messages: Arc>>) - -> Vec -{ - use ::structure_visitor::StructureVisitor; - - let mut elements = vec![]; - - let fileLoader = Box::new(DummyFileLoader::new()); - let codemap = Rc::new(CodeMap::with_file_loader(fileLoader)); - - let krate = parse_crate(source, codemap.clone(), messages.clone()); - - if let Some(krate) = krate { - let mut visitor : StructureVisitor = StructureVisitor::new(&codemap); - visit::walk_crate(&mut visitor, &krate); - - elements = visitor.elements; - } - return elements; -} - -/* ----------------- ----------------- */ - - -use std::ffi::OsStr; - -/// A FileLoader that loads any file successfully -pub struct DummyFileLoader { - modName : &'static OsStr, -} - -impl DummyFileLoader { - fn new() -> DummyFileLoader { - DummyFileLoader { modName : OsStr::new("mod.rs") } - } -} - -impl codemap::FileLoader for DummyFileLoader { - fn file_exists(&self, path: &Path) -> bool { - return path.file_name() == Some(self.modName); - } - - fn abs_path(&self, path: &Path) -> Option { - if path.is_absolute() { - Some(path.to_path_buf()) - } else { - env::current_dir().ok().map(|cwd| cwd.join(path)) - } - } - - fn read_file(&self, _path: &Path) -> io::Result { - Ok(String::new()) - } -} - - -struct MessagesHandler { - codemap : Rc, - messages : Arc>>, -} - - -fn parse_crate<'a>(source: &str, codemap: Rc, messages: Arc>>) -> Option -{ - let emitter = MessagesHandler::new(codemap.clone(), messages.clone()); - - let handler = Handler::with_emitter(true, false, Box::new(emitter)); - let sess = ParseSess::with_span_handler(handler, codemap.clone()); - - let krate_result = parse_crate_do(source, &sess); - - return match krate_result { - Ok(_krate) => { - Some(_krate) - } - Err(mut db) => { - db.emit(); - None - } - } -} - -pub fn parse_crate_do<'a>(source : &str, sess : &'a ParseSess) -> parse::PResult<'a, ast::Crate> -{ - let source = source.to_string(); - - let name = "_file_module_".to_string(); - -// We inlined: let mut parser = parse::new_parser_from_source_str(&sess, cfg, name, source); - - let filemap = sess.codemap().new_filemap(name, None, source); - - // filemap_to_tts but without a panic - let tts = - { - let srdr = parse::lexer::StringReader::new(&sess.span_diagnostic, filemap); - let mut p1 = parse::parser::Parser::new(sess, Box::new(srdr)); - - try!(p1.parse_all_token_trees()) - }; - - let trdr = parse::lexer::new_tt_reader(&sess.span_diagnostic, None, tts); - let mut parser = parse::parser::Parser::new(sess, Box::new(trdr)); - - return parser.parse_crate_mod(); -} - - - - -impl MessagesHandler { - - fn new(codemap: Rc, messages: Arc>>) -> MessagesHandler { - MessagesHandler { codemap : codemap, messages : messages } - } - - fn write_message_handled(&mut self, sourcerange : Option, msg: &str, severity: Severity) { - - let msg = SourceMessage{ severity : severity , sourcerange : sourcerange, message : String::from(msg) }; - - let mut messages = self.messages.lock().unwrap(); - messages.push(msg); - } - -} - -impl emitter::Emitter for MessagesHandler { - - fn emit(&mut self, db: &DiagnosticBuilder) { - let msg: &str = &db.message; - let code: Option<&String> = db.code.as_ref(); - let lvl: Level = db.level; - - let multispan : &MultiSpan = &db.span; - - if let Some(code) = code { - io::stderr().write_fmt(format_args!("Code: {}\n", code)).unwrap(); - panic!("What is code: Option<&str>??"); - } - - let sourceranges : Vec<_> = multispan.primary_spans().iter() - .map(|span| -> SourceRange { SourceRange::new(&self.codemap, *span)}) - .collect(); - - for sourcerange in sourceranges { - self.write_message_handled(Some(sourcerange), msg, level_to_status_level(lvl)); - } - } -} - -fn level_to_status_level(lvl: Level) -> Severity { - match lvl { - Level::PhaseFatal => panic!("Level::PhaseFatal"), - Level::Bug => panic!("Level::BUG"), - Level::Cancelled => panic!("Level::CANCELLED"), - Level::Help | Level::Note => Severity::INFO, - Level::Warning => Severity::WARNING, - Level::Error | Level::Fatal => Severity::ERROR, - } -} - -impl MessagesHandler { -} - - -/* ----------------- describe writting ----------------- */ - -pub fn write_parse_analysis_do(messages: Vec, elements: Vec, - out : Rc>) -> Void { - - let mut tokenWriter = TokenWriter { out : out }; - - try!(tokenWriter.write_raw("RUST_PARSE_DESCRIBE 1.0 {\n")); - try!(write_parse_analysis_contents(messages, elements, &mut tokenWriter)); - try!(tokenWriter.write_raw("\n}")); - - Ok(()) -} - -pub fn write_parse_analysis_contents(messages: Vec, elements: Vec, - tokenWriter : &mut TokenWriter) -> Void { - - try!(tokenWriter.write_raw("MESSAGES {\n")); - for msg in messages { - try!(output_message(tokenWriter, msg.sourcerange, &msg.message, &msg.severity)); - } - try!(tokenWriter.write_raw("}\n")); - - - for element in elements { - try!(write_structure_element(tokenWriter, &element, 0)); - } - - Ok(()) -} - -fn output_message(tokenWriter: &mut TokenWriter, opt_sr : Option, msg: & str, lvl: &Severity) - -> Void -{ - - try!(tokenWriter.write_raw("{ ")); - - try!(output_Level(&lvl, tokenWriter)); - - try!(output_opt_SourceRange(&opt_sr, tokenWriter)); - - try!(tokenWriter.write_string_token(msg)); - - try!(tokenWriter.write_raw("}\n")); - - Ok(()) -} - - -pub fn output_Level(lvl : &Severity, writer : &mut TokenWriter) -> Void { - - try!(writer.write_raw_token(lvl.to_string())); - - Ok(()) -} - -pub fn output_SourceRange(sr : &SourceRange, tw : &mut TokenWriter) -> Void { - try!(tw.write_raw("{ ")); - { - let mut out = tw.get_output(); - try!(out.write_fmt(format_args!("{}:{} {}:{} ", - sr.start_pos.line-1, sr.start_pos.col.0, - sr.end_pos.line-1, sr.end_pos.col.0, - ))); - } - try!(tw.write_raw("}")); - - Ok(()) -} - -pub fn output_opt_SourceRange(sr : &Option, writer : &mut TokenWriter) -> Void { - - match sr { - &None => try!(writer.write_raw("{ }")) , - &Some(ref sr) => try!(output_SourceRange(sr, writer)) , - } - - try!(writer.write_raw(" ")); - - Ok(()) -} - - -pub fn write_indent(tokenWriter : &mut TokenWriter, level : u32) -> Void { - try!(writeNTimes(&mut *tokenWriter.get_output(), ' ', level * 2)); - Ok(()) -} - -pub fn write_structure_element(tw : &mut TokenWriter, element: &StructureElement, level: u32) -> Void -{ - try!(tw.write_raw_token(element.kind.to_string())); - - try!(tw.write_raw("{ ")); - - try!(tw.write_string_token(&element.name)); - - try!(output_SourceRange(&element.sourcerange, tw)); - - try!(tw.get_output().write_str(" {}")); // name source range, Not Supported - - try!(tw.get_output().write_str(" ")); - try!(tw.write_string_token(&element.type_desc)); - - try!(tw.get_output().write_str("{}")); // attribs, Not Supported - - if element.children.is_empty() { - try!(tw.get_output().write_str(" ")); - } else { - let level = level + 1; - - for child in &element.children { - try!(tw.get_output().write_str("\n")); - try!(write_indent(tw, level)); - try!(write_structure_element(tw, child, level)); - } - - try!(tw.get_output().write_str("\n")); - try!(write_indent(tw, level-1)); - } - - try!(tw.get_output().write_str("}")); - - Ok(()) -} - - -#[cfg(test)] -mod parse_describe_tests { - - use parse_describe::*; - use source_model::*; - use token_writer::TokenWriter; - use util::core::*; - use util::tests::check_equal; - use util; - use std::rc::Rc; - use std::cell::RefCell; - - fn test_write_structure_element(name : &str, kind : StructureElementKind, sr: SourceRange, type_desc : String, - expected : &str, - ) { - let stringRc = Rc::new(RefCell::new(String::new())); - { - let name = String::from(name); - let element = StructureElement { name: name, kind: kind, sourcerange: sr, type_desc: type_desc, - children: vec![]}; - let mut tw = TokenWriter { out : stringRc.clone() }; - - write_structure_element(&mut tw, &element, 0).ok(); - } - - assert_eq!(unwrap_Rc_RefCell(stringRc).trim(), expected); - } - - #[test] - fn write_structure_element__tests() { - test_write_structure_element("blah", StructureElementKind::Var, source_range(1, 0, 2, 5), "desc".to_string(), - r#"Var { "blah" { 0:0 1:5 } {} "desc" {} }"#); - } - - - #[test] - fn parse_analysis__tests() { - test_parse_analysis("", ""); - - test_parse_analysis(" #blah ", r#"{ ERROR { 0:2 0:6 } "expected `[`, found `blah`" }"#); - - test_parse_analysis("fn foo(\n blah", r#" -{ ERROR { 1:6 1:6 } "this file contains an un-closed delimiter" } -{ ERROR { 1:6 1:6 } "expected one of `:` or `@`, found `)`" } -{ ERROR { 1:6 1:6 } "expected one of `->`, `where`, or `{`, found ``" } -"# - ); - - // Test a lexer panic - test_parse_analysis("const a = '", - r#"{ ERROR { 0:10 0:11 } "character literal may only contain one codepoint: '" }"# - ); - - // test `?` syntax shorthand for try: - test_parse_analysis("fn foo() { 123? }", - &("}\n".to_string() + r#"Function { "foo" { 0:0 0:17 } {} "()" {}"#) - ); - } - - fn test_parse_analysis(source : &str, expected_msgs : &str) { - let result = parse_analysis(source, String::new()).ok().unwrap(); - let mut result : &str = &result; - - result = assert_surrounding_string("RUST_PARSE_DESCRIBE 1.0 {", result, "}"); - - result = assert_starts_with("MESSAGES {", result.trim()); - expected_msgs.replace("\r\n", "\n"); - result = assert_starts_with(expected_msgs.trim(), result.trim()); - check_equal(result.trim(), "}"); - } - - fn assert_surrounding_string<'a> (start : &str, string : &'a str, end : &str) -> &'a str { - let mut string : &str = string; - - string = assert_starts_with(start, string); - string = assert_ends_with(string, end); - - return string; - } - - fn assert_starts_with<'a>(start : &str, string : &'a str) -> &'a str { - util::tests::assert_starts_with(string, start); - return &string[start.len() .. ]; - } - - fn assert_ends_with<'a> (string : &'a str, end : &str) -> &'a str { - assert!(string.ends_with(end), "`{}` does not end with `{}`", string, end); - return &string[0 .. string.len() - end.len()]; - } - -} \ No newline at end of file +// Copyright 2015 Bruno Medeiros +// +// 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. + +use source_model::*; +use util::core::*; +use util::string::*; + +use syntex_errors::emitter; +use syntex_errors::{DiagnosticBuilder, Handler, Level}; +use syntex_syntax::codemap::{self, CodeMap, FilePathMapping, MultiSpan}; +use syntex_syntax::parse::{self, ParseSess}; +use syntex_syntax::syntax::ast; +use syntex_syntax::tokenstream::TokenStream; +use syntex_syntax::visit; + +use std::boxed::Box; +use std::path::Path; + +use token_writer::TokenWriter; + +use std::cell::RefCell; +use std::env; +use std::fmt; +use std::io; +use std::io::Write; +use std::path::PathBuf; +use std::rc::*; + +/* ----------------- ----------------- */ + +pub fn parse_analysis_for_Stdout(source: &str) { + parse_analysis(source, StdoutWrite(io::stdout())).ok(); + println!(""); + io::stdout().flush().ok(); +} + +pub fn parse_analysis(source: &str, out: T) -> GResult { + let (messages, elements) = parse_crate_with_messages(source); + + let outRc = Rc::new(RefCell::new(out)); + try!(write_parse_analysis_do(messages, elements, outRc.clone())); + let res = unwrap_Rc_RefCell(outRc); + return Ok(res); +} + +use std::sync::{Arc, Mutex}; +use std::thread; + +pub fn parse_crate_with_messages(source: &str) -> (Vec, Vec) { + let messages = Arc::new(Mutex::new(vec![])); + let elements = { + let source = String::from(source); + let messages = messages.clone(); + + let worker_thread = thread::Builder::new().name("parser_thread".to_string()).spawn(move || parse_crate_with_messages_do(&source, messages)).unwrap(); + + worker_thread.join().unwrap_or(vec![]) + }; + + let messages: Mutex> = Arc::try_unwrap(messages).ok().unwrap(); + let messages: Vec = messages.into_inner().unwrap(); + + return (messages, elements); +} + +pub fn parse_crate_with_messages_do(source: &str, messages: Arc>>) -> Vec { + use structure_visitor::StructureVisitor; + + let mut elements = vec![]; + + let fileLoader = Box::new(DummyFileLoader::new()); + let codemap = Rc::new(CodeMap::with_file_loader(fileLoader, FilePathMapping::empty())); + + let krate = parse_crate(source, codemap.clone(), messages.clone()); + + if let Some(krate) = krate { + let mut visitor: StructureVisitor = StructureVisitor::new(&codemap); + visit::walk_crate(&mut visitor, &krate); + + elements = visitor.elements; + } + return elements; +} + +/* ----------------- ----------------- */ + +use std::ffi::OsStr; + +/// A FileLoader that loads any file successfully +pub struct DummyFileLoader { + modName: &'static OsStr, +} + +impl DummyFileLoader { + fn new() -> DummyFileLoader { + DummyFileLoader { modName: OsStr::new("mod.rs") } + } +} + +impl codemap::FileLoader for DummyFileLoader { + fn file_exists(&self, path: &Path) -> bool { + return path.file_name() == Some(self.modName); + } + + fn abs_path(&self, path: &Path) -> Option { + if path.is_absolute() { + Some(path.to_path_buf()) + } else { + env::current_dir().ok().map(|cwd| cwd.join(path)) + } + } + + fn read_file(&self, _path: &Path) -> io::Result { + Ok(String::new()) + } +} + +struct MessagesHandler { + codemap: Rc, + messages: Arc>>, +} + +fn parse_crate<'a>(source: &str, codemap: Rc, messages: Arc>>) -> Option { + let emitter = MessagesHandler::new(codemap.clone(), messages.clone()); + + let handler = Handler::with_emitter(true, false, Box::new(emitter)); + let sess = ParseSess::with_span_handler(handler, codemap.clone()); + + let krate_result = parse_crate_do(source, &sess); + + return match krate_result { + Ok(_krate) => Some(_krate), + Err(mut db) => { + db.emit(); + None + } + }; +} + +pub fn parse_crate_do<'a>(source: &str, sess: &'a ParseSess) -> parse::PResult<'a, ast::Crate> { + let source = source.to_string(); + let name = "_file_module_".to_string(); + let filemap = sess.codemap().new_filemap(name, source); + + let tts = { + let mut p1 = parse::filemap_to_parser(sess, filemap); + p1.parse_all_token_trees()?.into_iter().map(|tt| tt.into()).collect::>() + }; + + let mut parser = parse::parser::Parser::new(sess, TokenStream::concat(tts), None, false, false); + parser.parse_crate_mod() +} + +impl MessagesHandler { + fn new(codemap: Rc, messages: Arc>>) -> MessagesHandler { + MessagesHandler { codemap: codemap, messages: messages } + } + + fn write_message_handled(&mut self, sourcerange: Option, msg: &str, severity: Severity) { + let msg = SourceMessage { + severity: severity, + sourcerange: sourcerange, + message: String::from(msg), + }; + + let mut messages = self.messages.lock().unwrap(); + messages.push(msg); + } +} + +impl emitter::Emitter for MessagesHandler { + fn emit(&mut self, db: &DiagnosticBuilder) { + let msg = db.message(); + let msg = msg.as_str(); + let code: Option<&String> = db.code.as_ref(); + let lvl: Level = db.level; + + let multispan: &MultiSpan = &db.span; + + if let Some(code) = code { + io::stderr().write_fmt(format_args!("Code: {}\n", code)).unwrap(); + panic!("What is code: Option<&str>??"); + } + + let sourceranges: Vec<_> = multispan.primary_spans().iter().map(|span| -> SourceRange { SourceRange::new(&self.codemap, *span) }).collect(); + + for sourcerange in sourceranges { + self.write_message_handled(Some(sourcerange), msg, level_to_status_level(lvl)); + } + } +} + +fn level_to_status_level(lvl: Level) -> Severity { + match lvl { + Level::PhaseFatal => panic!("Level::PhaseFatal"), + Level::Bug => panic!("Level::BUG"), + Level::Cancelled => panic!("Level::CANCELLED"), + Level::Help | Level::Note => Severity::INFO, + Level::Warning => Severity::WARNING, + Level::Error | Level::Fatal => Severity::ERROR, + } +} + +impl MessagesHandler {} + +/* ----------------- describe writting ----------------- */ + +pub fn write_parse_analysis_do(messages: Vec, elements: Vec, out: Rc>) -> Void { + let mut tokenWriter = TokenWriter { out: out }; + + try!(tokenWriter.write_raw("RUST_PARSE_DESCRIBE 1.0 {\n")); + try!(write_parse_analysis_contents(messages, elements, &mut tokenWriter)); + try!(tokenWriter.write_raw("\n}")); + + Ok(()) +} + +pub fn write_parse_analysis_contents(messages: Vec, elements: Vec, tokenWriter: &mut TokenWriter) -> Void { + try!(tokenWriter.write_raw("MESSAGES {\n")); + for msg in messages { + try!(output_message(tokenWriter, msg.sourcerange, &msg.message, &msg.severity)); + } + try!(tokenWriter.write_raw("}\n")); + + for element in elements { + try!(write_structure_element(tokenWriter, &element, 0)); + } + + Ok(()) +} + +fn output_message(tokenWriter: &mut TokenWriter, opt_sr: Option, msg: &str, lvl: &Severity) -> Void { + try!(tokenWriter.write_raw("{ ")); + + try!(output_Level(&lvl, tokenWriter)); + + try!(output_opt_SourceRange(&opt_sr, tokenWriter)); + + try!(tokenWriter.write_string_token(msg)); + + try!(tokenWriter.write_raw("}\n")); + + Ok(()) +} + +pub fn output_Level(lvl: &Severity, writer: &mut TokenWriter) -> Void { + try!(writer.write_raw_token(lvl.to_string())); + + Ok(()) +} + +pub fn output_SourceRange(sr: &SourceRange, tw: &mut TokenWriter) -> Void { + try!(tw.write_raw("{ ")); + { + let mut out = tw.get_output(); + try!(out.write_fmt(format_args!("{}:{} {}:{} ", sr.start_pos.line - 1, sr.start_pos.col.0, sr.end_pos.line - 1, sr.end_pos.col.0,))); + } + try!(tw.write_raw("}")); + + Ok(()) +} + +pub fn output_opt_SourceRange(sr: &Option, writer: &mut TokenWriter) -> Void { + match sr { + &None => try!(writer.write_raw("{ }")), + &Some(ref sr) => try!(output_SourceRange(sr, writer)), + } + + try!(writer.write_raw(" ")); + + Ok(()) +} + +pub fn write_indent(tokenWriter: &mut TokenWriter, level: u32) -> Void { + try!(writeNTimes(&mut *tokenWriter.get_output(), ' ', level * 2)); + Ok(()) +} + +pub fn write_structure_element(tw: &mut TokenWriter, element: &StructureElement, level: u32) -> Void { + try!(tw.write_raw_token(element.kind.to_string())); + + try!(tw.write_raw("{ ")); + + try!(tw.write_string_token(&element.name)); + + try!(output_SourceRange(&element.sourcerange, tw)); + + try!(tw.get_output().write_str(" {}")); // name source range, Not Supported + + try!(tw.get_output().write_str(" ")); + try!(tw.write_string_token(&element.type_desc)); + + try!(tw.get_output().write_str("{}")); // attribs, Not Supported + + if element.children.is_empty() { + try!(tw.get_output().write_str(" ")); + } else { + let level = level + 1; + + for child in &element.children { + try!(tw.get_output().write_str("\n")); + try!(write_indent(tw, level)); + try!(write_structure_element(tw, child, level)); + } + + try!(tw.get_output().write_str("\n")); + try!(write_indent(tw, level - 1)); + } + + try!(tw.get_output().write_str("}")); + + Ok(()) +} + +#[cfg(test)] +mod parse_describe_tests { + + use parse_describe::*; + use source_model::*; + use std::cell::RefCell; + use std::rc::Rc; + use token_writer::TokenWriter; + use util; + use util::core::*; + use util::tests::check_equal; + + fn test_write_structure_element(name: &str, kind: StructureElementKind, sr: SourceRange, type_desc: String, expected: &str) { + let stringRc = Rc::new(RefCell::new(String::new())); + { + let name = String::from(name); + let element = StructureElement { + name: name, + kind: kind, + sourcerange: sr, + type_desc: type_desc, + children: vec![], + }; + let mut tw = TokenWriter { out: stringRc.clone() }; + + write_structure_element(&mut tw, &element, 0).ok(); + } + + assert_eq!(unwrap_Rc_RefCell(stringRc).trim(), expected); + } + + #[test] + fn write_structure_element__tests() { + test_write_structure_element("blah", StructureElementKind::Var, source_range(1, 0, 2, 5), "desc".to_string(), r#"Var { "blah" { 0:0 1:5 } {} "desc" {} }"#); + } + + #[test] + fn parse_analysis__tests() { + test_parse_analysis("", ""); + + test_parse_analysis(" #blah ", r#"{ ERROR { 0:2 0:6 } "expected `[`, found `blah`" }"#); + + test_parse_analysis( + "fn foo(\n blah", + r#" +{ ERROR { 1:6 1:6 } "this file contains an un-closed delimiter" } +{ ERROR { 1:6 1:6 } "expected one of `:` or `@`, found `)`" } +{ ERROR { 1:6 1:6 } "expected one of `->`, `where`, or `{`, found ``" } +"#, + ); + + // Test a lexer panic + test_parse_analysis("const a = '", r#"{ ERROR { 0:10 0:11 } "character literal may only contain one codepoint: '" }"#); + + // test `?` syntax shorthand for try: + test_parse_analysis("fn foo() { 123? }", &("}\n".to_string() + r#"Function { "foo" { 0:0 0:17 } {} "()" {}"#)); + } + + fn test_parse_analysis(source: &str, expected_msgs: &str) { + let result = parse_analysis(source, String::new()).ok().unwrap(); + let mut result: &str = &result; + + result = assert_surrounding_string("RUST_PARSE_DESCRIBE 1.0 {", result, "}"); + + result = assert_starts_with("MESSAGES {", result.trim()); + expected_msgs.replace("\r\n", "\n"); + result = assert_starts_with(expected_msgs.trim(), result.trim()); + check_equal(result.trim(), "}"); + } + + fn assert_surrounding_string<'a>(start: &str, string: &'a str, end: &str) -> &'a str { + let mut string: &str = string; + + string = assert_starts_with(start, string); + string = assert_ends_with(string, end); + + return string; + } + + fn assert_starts_with<'a>(start: &str, string: &'a str) -> &'a str { + util::tests::assert_starts_with(string, start); + return &string[start.len()..]; + } + + fn assert_ends_with<'a>(string: &'a str, end: &str) -> &'a str { + assert!(string.ends_with(end), "`{}` does not end with `{}`", string, end); + return &string[0..string.len() - end.len()]; + } + +} diff --git a/src/source_model.rs b/src/source_model.rs index 869bc85..e3e700d 100644 --- a/src/source_model.rs +++ b/src/source_model.rs @@ -1,131 +1,125 @@ -// Copyright 2016 Bruno Medeiros -// -// 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. - -use ::syntex_syntax::codemap:: { Span, Loc, CodeMap, CharPos}; - - -#[derive(Debug, Clone, Copy)] -pub struct LineColumnPosition { - /// The (1-based) line number - pub line: usize, - /// The (0-based) column offset - pub col: CharPos, - -} - -#[derive(Debug, Clone, Copy)] -pub struct SourceRange { - pub start_pos : LineColumnPosition, - pub end_pos : LineColumnPosition, -} - -impl SourceRange { - pub fn new(codemap : &CodeMap, span : Span) -> SourceRange { - let startLoc = codemap.lookup_char_pos(span.lo); - let endLoc = codemap.lookup_char_pos(span.hi); - - SourceRange::from_loc(startLoc, endLoc) - } - - pub fn from_loc(startLoc : Loc, endLoc : Loc) -> SourceRange { - SourceRange{ - start_pos : LineColumnPosition{ line: startLoc.line, col : startLoc.col }, - end_pos : LineColumnPosition{ line: endLoc.line, col : endLoc.col }, - } - } - -} - -pub fn source_range(start_line : usize, start_col : usize, end_line : usize, end_col : usize) -> SourceRange { - SourceRange { - start_pos : LineColumnPosition { line : start_line, col : CharPos(start_col) }, - end_pos : LineColumnPosition { line : end_line, col : CharPos(end_col) }, - } -} - - -/* ----------------- ----------------- */ - -//use ::util::core::*; - -pub enum Severity { - INFO, - WARNING, - ERROR, -} - -impl Severity { - pub fn to_string(&self) -> &'static str { - match *self { - Severity::ERROR => "ERROR", - Severity::WARNING => "WARNING", - Severity::INFO => "INFO", - } - } -} - - -pub struct SourceMessage { - pub severity : Severity, - pub sourcerange : Option, - pub message : String, -} - -/* ----------------- Model ----------------- */ - -pub enum StructureElementKind { - Var, - Function, - Struct, - Union, - Impl, - Trait, - Enum, - EnumVariant, - ExternCrate, - Mod, - Use, - MacroDef, // FIXME: not actually created at the moment - TypeAlias, -} - - -impl StructureElementKind { - pub fn to_string(&self) -> &'static str { - match *self { - StructureElementKind::Var => "Var", - StructureElementKind::Function => "Function", - StructureElementKind::Struct => "Struct", - StructureElementKind::Union => "Union", - StructureElementKind::Impl => "Impl", - StructureElementKind::Trait => "Trait", - StructureElementKind::Enum => "Enum", - StructureElementKind::EnumVariant => "EnumVariant", - StructureElementKind::ExternCrate => "ExternCrate", - StructureElementKind::Mod => "Mod", - StructureElementKind::Use => "Use", - StructureElementKind::MacroDef => "Macro", - StructureElementKind::TypeAlias => "TypeAlias", - } - } -} - -pub struct StructureElement { - pub name: String, - pub kind: StructureElementKind, - pub sourcerange: SourceRange, - - pub type_desc: String, - pub children: Vec, -} \ No newline at end of file +// Copyright 2016 Bruno Medeiros +// +// 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. + +use syntex_syntax::codemap::{CharPos, CodeMap, Loc, Span}; + +#[derive(Debug, Clone, Copy)] +pub struct LineColumnPosition { + /// The (1-based) line number + pub line: usize, + /// The (0-based) column offset + pub col: CharPos, +} + +#[derive(Debug, Clone, Copy)] +pub struct SourceRange { + pub start_pos: LineColumnPosition, + pub end_pos: LineColumnPosition, +} + +impl SourceRange { + pub fn new(codemap: &CodeMap, span: Span) -> SourceRange { + let startLoc = codemap.lookup_char_pos(span.lo); + let endLoc = codemap.lookup_char_pos(span.hi); + + SourceRange::from_loc(startLoc, endLoc) + } + + pub fn from_loc(startLoc: Loc, endLoc: Loc) -> SourceRange { + SourceRange { + start_pos: LineColumnPosition { line: startLoc.line, col: startLoc.col }, + end_pos: LineColumnPosition { line: endLoc.line, col: endLoc.col }, + } + } +} + +pub fn source_range(start_line: usize, start_col: usize, end_line: usize, end_col: usize) -> SourceRange { + SourceRange { + start_pos: LineColumnPosition { line: start_line, col: CharPos(start_col) }, + end_pos: LineColumnPosition { line: end_line, col: CharPos(end_col) }, + } +} + +/* ----------------- ----------------- */ + +//use ::util::core::*; + +pub enum Severity { + INFO, + WARNING, + ERROR, +} + +impl Severity { + pub fn to_string(&self) -> &'static str { + match *self { + Severity::ERROR => "ERROR", + Severity::WARNING => "WARNING", + Severity::INFO => "INFO", + } + } +} + +pub struct SourceMessage { + pub severity: Severity, + pub sourcerange: Option, + pub message: String, +} + +/* ----------------- Model ----------------- */ + +pub enum StructureElementKind { + Var, + Function, + Struct, + Union, + Impl, + Trait, + Enum, + EnumVariant, + ExternCrate, + Mod, + Use, + MacroDef, // FIXME: not actually created at the moment + TypeAlias, +} + +impl StructureElementKind { + pub fn to_string(&self) -> &'static str { + match *self { + StructureElementKind::Var => "Var", + StructureElementKind::Function => "Function", + StructureElementKind::Struct => "Struct", + StructureElementKind::Union => "Union", + StructureElementKind::Impl => "Impl", + StructureElementKind::Trait => "Trait", + StructureElementKind::Enum => "Enum", + StructureElementKind::EnumVariant => "EnumVariant", + StructureElementKind::ExternCrate => "ExternCrate", + StructureElementKind::Mod => "Mod", + StructureElementKind::Use => "Use", + StructureElementKind::MacroDef => "Macro", + StructureElementKind::TypeAlias => "TypeAlias", + } + } +} + +pub struct StructureElement { + pub name: String, + pub kind: StructureElementKind, + pub sourcerange: SourceRange, + + pub type_desc: String, + pub children: Vec, +} diff --git a/src/structure_visitor.rs b/src/structure_visitor.rs index 6b6fc63..5b0fa14 100644 --- a/src/structure_visitor.rs +++ b/src/structure_visitor.rs @@ -1,660 +1,619 @@ -// Copyright 2015 Bruno Medeiros -// -// 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. - - -//! -//! Write a parse structure into a TokenWriter -//! - -use std; - -use util::core::*; -use source_model::*; - -use syntex_syntax::visit::*; -use syntex_syntax::ast::*; -use syntex_syntax::codemap:: { Span, CodeMap }; - -pub struct StructureVisitor<'ps> { - pub codemap : & 'ps CodeMap, - pub parentIsStruct : bool, - pub parentIsUnion : bool, - pub elements : Vec, -} - -impl<'ps> StructureVisitor<'ps> { - - pub fn new(codemap : &'ps CodeMap) -> StructureVisitor<'ps> { - StructureVisitor { - codemap : codemap, parentIsStruct : false, parentIsUnion : false, elements : vec![] - } - } - - pub fn write_element_do( - &mut self, - ident: &str, - kind: StructureElementKind, - sourcerange: SourceRange, - type_desc: String, - walkFn: FN - ) -> Void - where FN : Fn(&mut Self) - { - - let mut siblings = vec![]; - std::mem::swap(&mut self.elements, &mut siblings); - - walkFn(self); // self.elements now has children - - std::mem::swap(&mut self.elements, &mut siblings); - let children = siblings; - - let element = StructureElement{ - name: String::from(ident), - kind: kind, - sourcerange: sourcerange , - type_desc : type_desc, - children : children - }; - - self.elements.push(element); - Ok(()) - } - - pub fn write_element_handled( - &mut self, - ident: &str, - kind : StructureElementKind, - sourceRange: SourceRange, - type_desc: String, - walkFn : FN) - where FN : Fn(&mut Self) - { - use std::io::Write; - - match - self.write_element_do(ident, kind, sourceRange, type_desc, walkFn) - { - Ok(ok) => { ok } - Err(error) => { - std::io::stderr().write_fmt(format_args!("Error writing element: {}", error)).ok(); - } - } - } - - pub fn write_element_TODO( - &mut self, - ident: Ident, - kind : StructureElementKind, span: Span, - walkFn : FN - ) - where FN : Fn(&mut Self) - { - self.write_element(ident, kind, span, "".to_string(), walkFn); - } - - pub fn write_element( - &mut self, - ident: Ident, - kind : StructureElementKind, - span: Span, - type_desc: String, walkFn : FN - ) - where FN : Fn(&mut Self) - { - self.write_element_handled(&*ident.name.as_str(), kind, SourceRange::new(self.codemap, span), - type_desc, walkFn) - } - - /* ----------------- ----------------- */ - - fn write_ItemUse(&mut self, vp : &ViewPath, span: Span) { - use syntex_syntax::print::pprust; - use syntex_syntax::ast; - use std::ops::Index; - - let kind = StructureElementKind::Use; - let mut useSpec = String::new(); - - fn writePath(outString : &mut String, path : &ast::Path) { - outString.push_str(&pprust::path_to_string(path)); - } - - match &vp.node { - &ViewPathSimple(ref ident, ref path) => { - writePath(&mut useSpec, path); - - let path : &ast::Path = path; - if path.segments.len() == 0 { - return; - } - let lastSegment = path.segments.index(path.segments.len() - 1); - if &lastSegment.identifier != ident { - useSpec.push_str(&" as "); - useSpec.push_str(&*ident.name.as_str()); - } - } - &ViewPathGlob(ref path) => { - useSpec.push_str(&pprust::path_to_string(path)); - useSpec.push_str(&"::*"); - } - &ViewPathList(ref path, ref pathListItem) => { - writePath(&mut useSpec, path); - - useSpec.push_str("::{ "); - for pitem in pathListItem { - let pitem : PathListItem_ = pitem.node; - - useSpec.push_str(&*pitem.name.name.as_str()); - if let Some(rename) = pitem.rename { - useSpec.push_str(" as "); - useSpec.push_str(&*rename.name.as_str()); - } - useSpec.push_str(", "); - } - useSpec.push_str("}"); - } - } - - self.write_element_handled(&useSpec, kind, SourceRange::new(self.codemap, span), "".to_string(), - &|_ : &mut Self| { }) - } - - fn get_type_desc_from_fndecl(&mut self, fd: &FnDecl) -> String { - - let mut type_desc = "".to_string(); - - type_desc.push('('); - let mut needs_sep = false; - - for arg in &fd.inputs { - let arg : &Arg = arg; -// let pat : &Pat_ = &arg.pat.node; - let pat_span = arg.pat.span; - - if needs_sep { - type_desc.push_str(", "); - } - needs_sep = true; - - if let Ok(snippet) = self.codemap.span_to_snippet(arg.ty.span) { - if !snippet.is_empty() { - type_desc.push_str(&snippet); - continue; - } - } - - if let Ok(snippet) = self.codemap.span_to_snippet(pat_span) { - if snippet.ends_with("self") { - type_desc.push_str(&snippet); - continue; - } - } - }; - type_desc.push_str(")"); - - if let FunctionRetTy::Ty(ref _ret) = fd.output { - if let Ok(ret_snippet) = self.codemap.span_to_snippet(fd.output.span()) { - type_desc.push_str(" -> "); - type_desc.push_str(&ret_snippet); - } - } - - type_desc - } - - fn write_function_element(&mut self, ident: Ident, span: Span, fd: & FnDecl, walkFn : &Fn(&mut Self)) { - let type_desc = self.get_type_desc_from_fndecl(&fd); - - self.write_element(ident, StructureElementKind::Function, span, type_desc, walkFn); - } - -} - -impl<'v> Visitor for StructureVisitor<'v> { - - fn visit_name(&mut self, _span: Span, _name: Name) { - // Nothing to do. - } - fn visit_ident(&mut self, span: Span, ident: Ident) { - walk_ident(self, span, ident); - } - - fn visit_mod(&mut self, m: &Mod, _span: Span, _nodeid: NodeId) { - -// let sr = &SourceRange::new(self.codemap, span); -// self.write_element_handled("_file_", StructureElementKind::File, sr, |_self : &mut Self| { -// walk_mod(_self, m); -// }) - walk_mod(self, m); - } - - fn visit_item(&mut self, item: &Item) { - - let kind; - let mut type_desc = "".to_string(); - - let noop_walkFn = &|_self : &mut Self| { }; - - let walkFn : &Fn(&mut Self) = &|_self : &mut Self| { - walk_item(_self, item); - }; - - match item.node { - ItemKind::ExternCrate(_opt_name) => { - kind = StructureElementKind::ExternCrate; - } - ItemKind::Use(ref vp) => { - self.write_ItemUse(vp, item.span); - return; - } - ItemKind::Static(ref typ, _, ref _expr) | - ItemKind::Const(ref typ, ref _expr) => { - - if let Ok(snippet) = self.codemap.span_to_snippet(typ.span) { - type_desc.push_str(&snippet); - } - self.write_element(item.ident, StructureElementKind::Var, item.span, type_desc, noop_walkFn); - return; - } - ItemKind::Fn(ref declaration, unsafety, constness, abi, ref generics, ref body) => { - self.visit_fn(FnKind::ItemFn(item.ident, generics, unsafety, constness, abi, &item.vis), - declaration, - body, - item.span, - item.id); - return; - } - ItemKind::Mod(ref _module) => { - kind = StructureElementKind::Mod; - } - ItemKind::ForeignMod(ref _foreign_module) => { - kind = StructureElementKind::Mod; - } - ItemKind::Ty(ref _typ, ref _type_parameters) => { - kind = StructureElementKind::TypeAlias; - } - ItemKind::Enum(ref _enum_definition, ref _type_parameters) => { - kind = StructureElementKind::Enum; - } - ItemKind::DefaultImpl(_, ref _trait_ref) => { - kind = StructureElementKind::Impl; - } - ItemKind::Impl(_, _, ref _type_parameters, ref _opt_trait_reference, ref _typ, ref _impl_items) => { - kind = StructureElementKind::Impl; - } - ItemKind::Struct(ref _struct_definition, ref _generics) => { - // Go straight in - self.parentIsStruct = true; - walk_item(self, item); - return; - } - ItemKind::Union(ref _struct_definition, ref _generics) => { - self.parentIsUnion = true; - walk_item(self, item); - return; - } - ItemKind::Trait(_, ref _generics, ref _bounds, ref _methods) => { - kind = StructureElementKind::Trait; - } - ItemKind::Mac(ref mac) => { - self.visit_mac(mac); - return; - } - } - - self.write_element(item.ident, kind, item.span, type_desc, walkFn); - } - - fn visit_enum_def(&mut self, enum_def: &EnumDef, generics: &Generics, nodeid: NodeId, _span: Span) { - // This element is covered by an item definition - walk_enum_def(self, enum_def, generics, nodeid) - } - - fn visit_variant(&mut self, v: &Variant, g: &Generics, nodeid: NodeId) { - // This element is covered by an enum_def call - walk_variant(self, v, g, nodeid); - } - - fn visit_variant_data(&mut self, s: &VariantData, ident: Ident, _: &Generics, _: NodeId, span: Span) { - let mut kind = StructureElementKind::EnumVariant; - if self.parentIsStruct { - kind = StructureElementKind::Struct; - self.parentIsStruct = false; - } - if self.parentIsUnion { - kind = StructureElementKind::Union; - self.parentIsUnion = false; - } - - self.write_element_TODO(ident, kind, span, |_self : &mut Self| { - walk_struct_def(_self, s); - }); - } - - fn visit_struct_field(&mut self, sf: &StructField) { - if let Some(ident) = sf.ident { - self.write_element_TODO(ident, StructureElementKind::Var, sf.span, |_self : &mut Self| { - walk_struct_field(_self, sf); - }); - } - } - - fn visit_trait_item(&mut self, ti: &TraitItem) { - let kind; - - match ti.node { - TraitItemKind::Const(ref _ty, ref _default) => { - kind = StructureElementKind::Var; - } - TraitItemKind::Method(ref sig, _) => { - self.write_function_element(ti.ident, ti.span, &sig.decl, &|_self : &mut Self| { - walk_trait_item(_self, ti); - }); - return; - } - TraitItemKind::Type(ref _bounds, ref _default) => { - kind = StructureElementKind::TypeAlias; - } - TraitItemKind::Macro(ref mac) => { - self.visit_mac(mac); - return; - } - } - - self.write_element_TODO(ti.ident, kind, ti.span, |_self : &mut Self| { - walk_trait_item(_self, ti); - }); - } - - fn visit_impl_item(&mut self, ii: &ImplItem) { - let kind; - - match ii.node { - ImplItemKind::Const(ref _ty, ref _default) => { - kind = StructureElementKind::Var; - } - ImplItemKind::Type(ref _type) => { - kind = StructureElementKind::TypeAlias; - } - ImplItemKind::Method(_, _) | - ImplItemKind::Macro(_) => { - walk_impl_item(self, ii); - return; - } - } - - self.write_element_TODO(ii.ident, kind, ii.span, |_self : &mut Self| { - walk_impl_item(_self, ii); - }); - } - - /* ----------------- Function ----------------- */ - - fn visit_fn(&mut self, fk: FnKind, fd: &FnDecl, b: &Block, span: Span, _nodeid: NodeId) { - - let ident : Ident; - - match fk { - FnKind::Method(_ident, ref _MethodSig, _option) => { - ident = _ident; - } - FnKind::ItemFn(_ident, ref _Generics, _Unsafety, _Constness, _Abi, _Visibility) => { - ident = _ident; - } - FnKind::Closure => { return; } - }; - - self.write_function_element(ident, span, fd, &|_self : &mut Self| { - walk_fn(_self, fk, fd, b, span); - }); - } - - fn visit_foreign_item(&mut self, foreign_item: &ForeignItem) { - let kind; - - match foreign_item.node { - ForeignItemKind::Fn(ref _function_declaration, ref _generics) => { - kind = StructureElementKind::Function; - } - ForeignItemKind::Static(ref _typ, _) => { - kind = StructureElementKind::Var; - } - } - - self.write_element_TODO(foreign_item.ident, kind, foreign_item.span, |_self : &mut Self| { - walk_foreign_item(_self, foreign_item); - }); - } - - - fn visit_trait_ref(&mut self, t: &TraitRef) { - walk_trait_ref(self, t) - } - fn visit_ty_param_bound(&mut self, bounds: &TyParamBound) { - walk_ty_param_bound(self, bounds) - } - fn visit_poly_trait_ref(&mut self, t: &PolyTraitRef, m: &TraitBoundModifier) { - walk_poly_trait_ref(self, t, m) - } - - fn visit_lifetime(&mut self, lifetime: &Lifetime) { - walk_lifetime(self, lifetime) - } - fn visit_lifetime_def(&mut self, lifetime: &LifetimeDef) { - walk_lifetime_def(self, lifetime) - } - - fn visit_local(&mut self, l: &Local) { - walk_local(self, l) - } - fn visit_block(&mut self, b: &Block) { - walk_block(self, b) - } - fn visit_stmt(&mut self, s: &Stmt) { - walk_stmt(self, s) - } - fn visit_arm(&mut self, a: &Arm) { - walk_arm(self, a) - } - fn visit_pat(&mut self, p: &Pat) { - walk_pat(self, p) - } - fn visit_expr(&mut self, _ex: &Expr) { - // Comment, no need to visit node insinde expressions - //walk_expr(self, ex) - } - fn visit_expr_post(&mut self, _ex: &Expr) { - } - fn visit_ty(&mut self, t: &Ty) { - walk_ty(self, t) - } - fn visit_generics(&mut self, g: &Generics) { - walk_generics(self, g) - } - - - fn visit_mac(&mut self, _mac: &Mac) { - //panic!("visit_mac disabled by default"); - - // NB: see note about macros above. - // if you really want a visitor that - // works on macros, use this - // definition in your trait impl: - // visit::walk_mac(self, _mac) - } - fn visit_path(&mut self, path: &Path, _id: NodeId) { - walk_path(self, path) - } - fn visit_path_list_item(&mut self, prefix: &Path, item: &PathListItem) { - walk_path_list_item(self, prefix, item) - } - fn visit_path_segment(&mut self, path_span: Span, path_segment: &PathSegment) { - walk_path_segment(self, path_span, path_segment) - } - fn visit_path_parameters(&mut self, path_span: Span, path_parameters: &PathParameters) { - walk_path_parameters(self, path_span, path_parameters) - } - fn visit_assoc_type_binding(&mut self, type_binding: &TypeBinding) { - walk_assoc_type_binding(self, type_binding) - } - fn visit_attribute(&mut self, _attr: &Attribute) { - } - fn visit_macro_def(&mut self, macro_def: &MacroDef) { - walk_macro_def(self, macro_def) - } - - fn visit_vis(&mut self, vis: &Visibility) { - walk_vis(self, vis) - } -} - - - -#[test] -fn tests_describe_structure() { - - use std::rc::Rc; - use std::cell::RefCell; - use parse_describe; - use token_writer::TokenWriter; - use util::tests::*; - - - fn test_describe_structure(source : &str, expected : &str) { - let stringRc = Rc::new(RefCell::new(String::new())); - - { - let (messages, elements) = parse_describe::parse_crate_with_messages(source); - - let mut tokenWriter = TokenWriter { out : stringRc.clone() }; - parse_describe::write_parse_analysis_contents(messages, elements, &mut tokenWriter).ok().unwrap(); - } - - let expected : &str = &(String::from("MESSAGES {\n}") + - (if expected.is_empty() { "" } else { "\n" }) + expected); - - let result = unwrap_Rc_RefCell(stringRc); - let result = result.trim(); - check_equal(result, expected); - } - - test_describe_structure("extern crate xx;", r#"ExternCrate { "xx" { 0:0 0:16 } {} "" {} }"#); - - test_describe_structure("const xx : u32 = 1;", r#"Var { "xx" { 0:0 0:19 } {} "u32" {} }"#); - - - test_describe_structure("mod myMod ; ", r#"Mod { "myMod" { 0:0 0:13 } {} "" {} }"#); - test_describe_structure("mod myMod { }", r#"Mod { "myMod" { 0:0 0:13 } {} "" {} }"#); - test_describe_structure("mod myMod { static xx : u32 = 2; }", -r#"Mod { "myMod" { 0:0 0:34 } {} "" {} - Var { "xx" { 0:12 0:32 } {} "u32" {} } -}"# - ); - - test_describe_structure("fn xx() { }", r#"Function { "xx" { 0:0 0:11 } {} "()" {} }"#); - test_describe_structure("fn xx(a : &str) -> u32 { }", - r#"Function { "xx" { 0:0 0:26 } {} "(&str) -> u32" {} }"#); - test_describe_structure("fn xx(blah : Vec, x : &'v str) -> u32 { }", - r#"Function { "xx" { 0:0 0:46 } {} "(Vec, &'v str) -> u32" {} }"#); - // Test "deceiving" case - test_describe_structure("fn xx(my_self : &str) -> u32 { }", - r#"Function { "xx" { 0:0 0:32 } {} "(&str) -> u32" {} }"#); - - test_describe_structure("type MyType = &u32;", r#"TypeAlias { "MyType" { 0:0 0:24 } {} "" {} }"#); - - test_describe_structure("enum MyEnum { Alpha, Beta, } ", -r#"Enum { "MyEnum" { 0:0 0:28 } {} "" {} - EnumVariant { "Alpha" { 0:14 0:19 } {} "" {} } - EnumVariant { "Beta" { 0:21 0:25 } {} "" {} } -}"#); - test_describe_structure("enum MyEnum { Alpha(T), Beta(U), } ", -r#"Enum { "MyEnum" { 0:0 0:40 } {} "" {} - EnumVariant { "Alpha" { 0:20 0:28 } {} "" {} } - EnumVariant { "Beta" { 0:30 0:37 } {} "" {} } -}"#); - - - test_describe_structure("struct MyStruct ( u32, blah ); ", -r#"Struct { "MyStruct" { 0:0 0:35 } {} "" {} }"#); - test_describe_structure("struct MyStruct { foo : u32, } ", -r#"Struct { "MyStruct" { 0:0 0:30 } {} "" {} - Var { "foo" { 0:18 0:27 } {} "" {} } -}"#); - test_describe_structure("union MyUnion { foo : u32, } ", -r#"Union { "MyUnion" { 0:0 0:28 } {} "" {} - Var { "foo" { 0:16 0:25 } {} "" {} } -}"#); - - test_describe_structure("trait MyTrait { } ", r#"Trait { "MyTrait" { 0:0 0:17 } {} "" {} }"#); - test_describe_structure("trait MyTrait : Foo { fn xxx(); } ", -r#"Trait { "MyTrait" { 0:0 0:33 } {} "" {} - Function { "xxx" { 0:22 0:31 } {} "()" {} } -}"#); - test_describe_structure("trait MyTrait : Foo { type N: fmt::Display; fn xxx(&self); const foo :u32 = 3; } ", -r#"Trait { "MyTrait" { 0:0 0:80 } {} "" {} - TypeAlias { "N" { 0:22 0:43 } {} "" {} } - Function { "xxx" { 0:44 0:58 } {} "(&self)" {} } - Var { "foo" { 0:59 0:78 } {} "" {} } -}"#); - - /* FIXME: review - test_describe_structure("impl MyType { } ", r#"Impl { "MyType" { 0:0 0:15 } {} "" {} }"#); - test_describe_structure("impl MyTrait for MyType { } ", r#"Impl { "MyType.MyTrait" { 0:0 0:27 } {} "" {} }"#); - test_describe_structure("impl MyTrait { type N= fmt::Display; fn xx(){} const foo :u32 = 3; } ", -r#"Impl { "MyTrait" { 0:0 0:75 } {} "" {} - TypeAlias { "N" { 0:22 0:43 } {} "" {} } - Function { "xx" { 0:44 0:53 } {} "()" {} } - Var { "foo" { 0:54 0:73 } {} "" {} } -}"#); - */ - - - test_describe_structure("use blah;", r#"Use { "blah" { 0:0 0:9 } {} "" {} }"#); - test_describe_structure("use blah as foo;", r#"Use { "blah as foo" { 0:0 0:16 } {} "" {} }"#); - // TODO: this is not printing the global path prefix, seems to be a limitation from libsyntax? - test_describe_structure("use ::blah::foo as myfoo;", r#"Use { "::blah::foo as myfoo" { 0:0 0:25 } {} "" {} }"#); - test_describe_structure("use ::blah::foo::*;", r#"Use { "::blah::foo::*" { 0:0 0:19 } {} "" {} }"#); - test_describe_structure("use blah::foo:: { One as OtherOne, self as Two };", - r#"Use { "blah::foo::{ One as OtherOne, self as Two, }" { 0:0 0:49 } {} "" {} }"#); - - - test_describe_structure("my_macro!(asf); ", ""); - - // test: visit_mac! visit method - test_describe_structure("fn foo() { my_macro!(asf); }", r#"Function { "foo" { 0:0 0:28 } {} "()" {} }"#); - - test_describe_structure("macro_rules! foo { (x => $e:expr) => (); }", r#""#); - // TODO: macro definitions, unfortunately can't get that info easily from syntax_syntex -// test_describe_structure("macro_rules! five_times { ($x:expr) => (5 * $x); }", -// r#"Macro { "foo" { 0:0 0:28 } {} "" {} }"#); - - // Test pub extern - test_describe_structure("pub extern crate my_crate;", - r#"ExternCrate { "my_crate" { 0:0 0:26 } {} "" {} }"# - ); - - test_describe_structure("extern { fn ext(p : u32); }", -r#"Mod { "" { 0:0 0:27 } {} "" {} - Function { "ext" { 0:9 0:25 } {} "" {} } -}"#); - test_describe_structure("extern { fn ext(p : u32); \n static extVar: u8; }", -r#"Mod { "" { 0:0 1:21 } {} "" {} - Function { "ext" { 0:9 0:25 } {} "" {} } - Var { "extVar" { 1:1 1:19 } {} "" {} } -}"#); - - // Test with a lexer error, -// test_describe_structure("const xx : u32 = '", r#"Var { "xx" { 1 0 1 19 } {} {} {} }"#); -} \ No newline at end of file +// Copyright 2015 Bruno Medeiros +// +// 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. + +//! +//! Write a parse structure into a TokenWriter +//! + +use std; + +use source_model::*; +use util::core::*; + +use syntex_syntax::ast::*; +use syntex_syntax::codemap::{CodeMap, Span}; +use syntex_syntax::visit::*; + +pub struct StructureVisitor<'ps> { + pub codemap: &'ps CodeMap, + pub parentIsStruct: bool, + pub parentIsUnion: bool, + pub elements: Vec, +} + +impl<'ps> StructureVisitor<'ps> { + pub fn new(codemap: &'ps CodeMap) -> StructureVisitor<'ps> { + StructureVisitor { + codemap: codemap, + parentIsStruct: false, + parentIsUnion: false, + elements: vec![], + } + } + + pub fn write_element_do(&mut self, ident: &str, kind: StructureElementKind, sourcerange: SourceRange, type_desc: String, walkFn: FN) -> Void + where + FN: Fn(&mut Self), + { + let mut siblings = vec![]; + std::mem::swap(&mut self.elements, &mut siblings); + + walkFn(self); // self.elements now has children + + std::mem::swap(&mut self.elements, &mut siblings); + let children = siblings; + + let element = StructureElement { + name: String::from(ident), + kind: kind, + sourcerange: sourcerange, + type_desc: type_desc, + children: children, + }; + + self.elements.push(element); + Ok(()) + } + + pub fn write_element_handled(&mut self, ident: &str, kind: StructureElementKind, sourceRange: SourceRange, type_desc: String, walkFn: FN) + where + FN: Fn(&mut Self), + { + use std::io::Write; + + match self.write_element_do(ident, kind, sourceRange, type_desc, walkFn) { + Ok(ok) => ok, + Err(error) => { + std::io::stderr().write_fmt(format_args!("Error writing element: {}", error)).ok(); + } + } + } + + pub fn write_element_TODO(&mut self, ident: Ident, kind: StructureElementKind, span: Span, walkFn: FN) + where + FN: Fn(&mut Self), + { + self.write_element(ident, kind, span, "".to_string(), walkFn); + } + + pub fn write_element(&mut self, ident: Ident, kind: StructureElementKind, span: Span, type_desc: String, walkFn: FN) + where + FN: Fn(&mut Self), + { + self.write_element_handled(&*ident.name.as_str(), kind, SourceRange::new(self.codemap, span), type_desc, walkFn) + } + + /* ----------------- ----------------- */ + + fn write_ItemUse(&mut self, vp: &ViewPath, span: Span) { + use std::ops::Index; + use syntex_syntax::ast; + use syntex_syntax::print::pprust; + + let kind = StructureElementKind::Use; + let mut useSpec = String::new(); + + fn writePath(outString: &mut String, path: &ast::Path) { + outString.push_str(&pprust::path_to_string(path)); + } + + match &vp.node { + &ViewPathSimple(ref ident, ref path) => { + writePath(&mut useSpec, path); + + let path: &ast::Path = path; + if path.segments.len() == 0 { + return; + } + let lastSegment = path.segments.index(path.segments.len() - 1); + if &lastSegment.identifier != ident { + useSpec.push_str(&" as "); + useSpec.push_str(&*ident.name.as_str()); + } + } + &ViewPathGlob(ref path) => { + useSpec.push_str(&pprust::path_to_string(path)); + useSpec.push_str(&"::*"); + } + &ViewPathList(ref path, ref pathListItem) => { + writePath(&mut useSpec, path); + + useSpec.push_str("::{ "); + for pitem in pathListItem { + let pitem: PathListItem_ = pitem.node; + + useSpec.push_str(&*pitem.name.name.as_str()); + if let Some(rename) = pitem.rename { + useSpec.push_str(" as "); + useSpec.push_str(&*rename.name.as_str()); + } + useSpec.push_str(", "); + } + useSpec.push_str("}"); + } + } + + self.write_element_handled(&useSpec, kind, SourceRange::new(self.codemap, span), "".to_string(), &|_: &mut Self| {}) + } + + fn get_type_desc_from_fndecl(&mut self, fd: &FnDecl) -> String { + let mut type_desc = "".to_string(); + + type_desc.push('('); + let mut needs_sep = false; + + for arg in &fd.inputs { + let arg: &Arg = arg; + // let pat : &Pat_ = &arg.pat.node; + let pat_span = arg.pat.span; + + if needs_sep { + type_desc.push_str(", "); + } + needs_sep = true; + + if let Ok(snippet) = self.codemap.span_to_snippet(arg.ty.span) { + if !snippet.is_empty() { + type_desc.push_str(&snippet); + continue; + } + } + + if let Ok(snippet) = self.codemap.span_to_snippet(pat_span) { + if snippet.ends_with("self") { + type_desc.push_str(&snippet); + continue; + } + } + } + type_desc.push_str(")"); + + if let FunctionRetTy::Ty(ref _ret) = fd.output { + if let Ok(ret_snippet) = self.codemap.span_to_snippet(fd.output.span()) { + type_desc.push_str(" -> "); + type_desc.push_str(&ret_snippet); + } + } + + type_desc + } + + fn write_function_element(&mut self, ident: Ident, span: Span, fd: &FnDecl, walkFn: &Fn(&mut Self)) { + let type_desc = self.get_type_desc_from_fndecl(&fd); + + self.write_element(ident, StructureElementKind::Function, span, type_desc, walkFn); + } +} + +impl<'v> Visitor<'v> for StructureVisitor<'v> { + fn visit_name(&mut self, _span: Span, _name: Name) { + // Nothing to do. + } + fn visit_ident(&mut self, span: Span, ident: Ident) { + walk_ident(self, span, ident); + } + + fn visit_mod(&mut self, m: &'v Mod, _span: Span, _attrs: &[Attribute], _nodeid: NodeId) { + // let sr = &SourceRange::new(self.codemap, span); + // self.write_element_handled("_file_", StructureElementKind::File, sr, |_self : &mut Self| { + // walk_mod(_self, m); + // }) + walk_mod(self, m); + } + + fn visit_item(&mut self, item: &'v Item) { + let kind; + let mut type_desc = "".to_string(); + + let noop_walkFn = &|_self: &mut Self| {}; + + let walkFn: &Fn(&mut Self) = &|_self: &mut Self| { + walk_item(_self, item); + }; + + match item.node { + ItemKind::ExternCrate(_opt_name) => { + kind = StructureElementKind::ExternCrate; + } + ItemKind::Use(ref vp) => { + self.write_ItemUse(vp, item.span); + return; + } + ItemKind::Static(ref typ, _, ref _expr) | ItemKind::Const(ref typ, ref _expr) => { + if let Ok(snippet) = self.codemap.span_to_snippet(typ.span) { + type_desc.push_str(&snippet); + } + self.write_element(item.ident, StructureElementKind::Var, item.span, type_desc, noop_walkFn); + return; + } + ItemKind::Fn(ref declaration, unsafety, constness, abi, ref generics, ref body) => { + self.visit_fn(FnKind::ItemFn(item.ident, generics, unsafety, constness, abi, &item.vis, body), declaration, item.span, item.id); + return; + } + ItemKind::Mod(ref _module) => { + kind = StructureElementKind::Mod; + } + ItemKind::ForeignMod(ref _foreign_module) => { + kind = StructureElementKind::Mod; + } + ItemKind::Ty(ref _typ, ref _type_parameters) => { + kind = StructureElementKind::TypeAlias; + } + ItemKind::Enum(ref _enum_definition, ref _type_parameters) => { + kind = StructureElementKind::Enum; + } + ItemKind::DefaultImpl(_, ref _trait_ref) => { + kind = StructureElementKind::Impl; + } + ItemKind::Impl(_, _, ref _type_parameters, _, ref _opt_trait_reference, ref _typ, ref _impl_items) => { + kind = StructureElementKind::Impl; + } + ItemKind::Struct(ref _struct_definition, ref _generics) => { + // Go straight in + self.parentIsStruct = true; + walk_item(self, item); + return; + } + ItemKind::Union(ref _struct_definition, ref _generics) => { + self.parentIsUnion = true; + walk_item(self, item); + return; + } + ItemKind::Trait(_, ref _generics, ref _bounds, ref _methods) => { + kind = StructureElementKind::Trait; + } + ItemKind::Mac(ref mac) => { + self.visit_mac(mac); + return; + } + ItemKind::GlobalAsm(ref asm) => { + self.visit_global_asm(asm); + return; + } + ItemKind::MacroDef(ref macro_def) => { + self.visit_mac_def(macro_def, item.id); + return; + } + } + + self.write_element(item.ident, kind, item.span, type_desc, walkFn); + } + + fn visit_enum_def(&mut self, enum_def: &'v EnumDef, generics: &'v Generics, nodeid: NodeId, _span: Span) { + // This element is covered by an item definition + walk_enum_def(self, enum_def, generics, nodeid) + } + + fn visit_variant(&mut self, v: &'v Variant, g: &'v Generics, nodeid: NodeId) { + // This element is covered by an enum_def call + walk_variant(self, v, g, nodeid); + } + + fn visit_variant_data(&mut self, s: &'v VariantData, ident: Ident, _: &'v Generics, _: NodeId, span: Span) { + let mut kind = StructureElementKind::EnumVariant; + if self.parentIsStruct { + kind = StructureElementKind::Struct; + self.parentIsStruct = false; + } + if self.parentIsUnion { + kind = StructureElementKind::Union; + self.parentIsUnion = false; + } + + self.write_element_TODO(ident, kind, span, |_self: &mut Self| { + walk_struct_def(_self, s); + }); + } + + fn visit_struct_field(&mut self, sf: &'v StructField) { + if let Some(ident) = sf.ident { + self.write_element_TODO(ident, StructureElementKind::Var, sf.span, |_self: &mut Self| { + walk_struct_field(_self, sf); + }); + } + } + + fn visit_trait_item(&mut self, ti: &'v TraitItem) { + let kind; + + match ti.node { + TraitItemKind::Const(ref _ty, ref _default) => { + kind = StructureElementKind::Var; + } + TraitItemKind::Method(ref sig, _) => { + self.write_function_element(ti.ident, ti.span, &sig.decl, &|_self: &mut Self| { + walk_trait_item(_self, ti); + }); + return; + } + TraitItemKind::Type(ref _bounds, ref _default) => { + kind = StructureElementKind::TypeAlias; + } + TraitItemKind::Macro(ref mac) => { + self.visit_mac(mac); + return; + } + } + + self.write_element_TODO(ti.ident, kind, ti.span, |_self: &mut Self| { + walk_trait_item(_self, ti); + }); + } + + fn visit_impl_item(&mut self, ii: &'v ImplItem) { + let kind; + + match ii.node { + ImplItemKind::Const(ref _ty, ref _default) => { + kind = StructureElementKind::Var; + } + ImplItemKind::Type(ref _type) => { + kind = StructureElementKind::TypeAlias; + } + ImplItemKind::Method(_, _) | ImplItemKind::Macro(_) => { + walk_impl_item(self, ii); + return; + } + } + + self.write_element_TODO(ii.ident, kind, ii.span, |_self: &mut Self| { + walk_impl_item(_self, ii); + }); + } + + /* ----------------- Function ----------------- */ + + fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, span: Span, _nodeid: NodeId) { + let ident: Ident; + + match fk { + FnKind::Method(_ident, ref _MethodSig, _option, _b) => { + ident = _ident; + } + FnKind::ItemFn(_ident, ref _Generics, _Unsafety, _Constness, _Abi, _Visibility, _b) => { + ident = _ident; + } + FnKind::Closure(_) => { + return; + } + }; + + self.write_function_element(ident, span, fd, &|_self: &mut Self| { + walk_fn(_self, fk, fd, span); + }); + } + + fn visit_foreign_item(&mut self, foreign_item: &'v ForeignItem) { + let kind; + + match foreign_item.node { + ForeignItemKind::Fn(ref _function_declaration, ref _generics) => { + kind = StructureElementKind::Function; + } + ForeignItemKind::Static(ref _typ, _) => { + kind = StructureElementKind::Var; + } + } + + self.write_element_TODO(foreign_item.ident, kind, foreign_item.span, |_self: &mut Self| { + walk_foreign_item(_self, foreign_item); + }); + } + + fn visit_trait_ref(&mut self, t: &'v TraitRef) { + walk_trait_ref(self, t) + } + fn visit_ty_param_bound(&mut self, bounds: &'v TyParamBound) { + walk_ty_param_bound(self, bounds) + } + fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: &'v TraitBoundModifier) { + walk_poly_trait_ref(self, t, m) + } + + fn visit_lifetime(&mut self, lifetime: &'v Lifetime) { + walk_lifetime(self, lifetime) + } + fn visit_lifetime_def(&mut self, lifetime: &'v LifetimeDef) { + walk_lifetime_def(self, lifetime) + } + + fn visit_local(&mut self, l: &'v Local) { + walk_local(self, l) + } + fn visit_block(&mut self, b: &'v Block) { + walk_block(self, b) + } + fn visit_stmt(&mut self, s: &'v Stmt) { + walk_stmt(self, s) + } + fn visit_arm(&mut self, a: &'v Arm) { + walk_arm(self, a) + } + fn visit_pat(&mut self, p: &'v Pat) { + walk_pat(self, p) + } + fn visit_expr(&mut self, _ex: &Expr) { + // Comment, no need to visit node insinde expressions + //walk_expr(self, ex) + } + fn visit_expr_post(&mut self, _ex: &Expr) {} + fn visit_ty(&mut self, t: &'v Ty) { + walk_ty(self, t) + } + fn visit_generics(&mut self, g: &'v Generics) { + walk_generics(self, g) + } + fn visit_mac(&mut self, mac: &Mac) { + walk_mac(self, mac) + } + fn visit_path(&mut self, path: &'v Path, _id: NodeId) { + walk_path(self, path) + } + fn visit_path_list_item(&mut self, prefix: &'v Path, item: &'v PathListItem) { + walk_path_list_item(self, prefix, item) + } + fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) { + walk_path_segment(self, path_span, path_segment) + } + fn visit_path_parameters(&mut self, path_span: Span, path_parameters: &'v PathParameters) { + walk_path_parameters(self, path_span, path_parameters) + } + fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding) { + walk_assoc_type_binding(self, type_binding) + } + fn visit_attribute(&mut self, _attr: &Attribute) {} + fn visit_vis(&mut self, vis: &'v Visibility) { + walk_vis(self, vis) + } +} + +#[test] +fn tests_describe_structure() { + use parse_describe; + use std::cell::RefCell; + use std::rc::Rc; + use token_writer::TokenWriter; + use util::tests::*; + + fn test_describe_structure(source: &str, expected: &str) { + let stringRc = Rc::new(RefCell::new(String::new())); + + { + let (messages, elements) = parse_describe::parse_crate_with_messages(source); + + let mut tokenWriter = TokenWriter { out: stringRc.clone() }; + parse_describe::write_parse_analysis_contents(messages, elements, &mut tokenWriter).ok().unwrap(); + } + + let expected: &str = &(String::from("MESSAGES {\n}") + (if expected.is_empty() { "" } else { "\n" }) + expected); + + let result = unwrap_Rc_RefCell(stringRc); + let result = result.trim(); + check_equal(result, expected); + } + + test_describe_structure("extern crate xx;", r#"ExternCrate { "xx" { 0:0 0:16 } {} "" {} }"#); + + test_describe_structure("const xx : u32 = 1;", r#"Var { "xx" { 0:0 0:19 } {} "u32" {} }"#); + + test_describe_structure("mod myMod ; ", r#"Mod { "myMod" { 0:0 0:13 } {} "" {} }"#); + test_describe_structure("mod myMod { }", r#"Mod { "myMod" { 0:0 0:13 } {} "" {} }"#); + test_describe_structure( + "mod myMod { static xx : u32 = 2; }", + r#"Mod { "myMod" { 0:0 0:34 } {} "" {} + Var { "xx" { 0:12 0:32 } {} "u32" {} } +}"#, + ); + + test_describe_structure("fn xx() { }", r#"Function { "xx" { 0:0 0:11 } {} "()" {} }"#); + test_describe_structure("fn xx(a : &str) -> u32 { }", r#"Function { "xx" { 0:0 0:26 } {} "(&str) -> u32" {} }"#); + test_describe_structure("fn xx(blah : Vec, x : &'v str) -> u32 { }", r#"Function { "xx" { 0:0 0:46 } {} "(Vec, &'v str) -> u32" {} }"#); + // Test "deceiving" case + test_describe_structure("fn xx(my_self : &str) -> u32 { }", r#"Function { "xx" { 0:0 0:32 } {} "(&str) -> u32" {} }"#); + + test_describe_structure("type MyType = &u32;", r#"TypeAlias { "MyType" { 0:0 0:24 } {} "" {} }"#); + + test_describe_structure( + "enum MyEnum { Alpha, Beta, } ", + r#"Enum { "MyEnum" { 0:0 0:28 } {} "" {} + EnumVariant { "Alpha" { 0:14 0:19 } {} "" {} } + EnumVariant { "Beta" { 0:21 0:25 } {} "" {} } +}"#, + ); + test_describe_structure( + "enum MyEnum { Alpha(T), Beta(U), } ", + r#"Enum { "MyEnum" { 0:0 0:40 } {} "" {} + EnumVariant { "Alpha" { 0:20 0:28 } {} "" {} } + EnumVariant { "Beta" { 0:30 0:37 } {} "" {} } +}"#, + ); + + test_describe_structure("struct MyStruct ( u32, blah ); ", r#"Struct { "MyStruct" { 0:0 0:35 } {} "" {} }"#); + test_describe_structure( + "struct MyStruct { foo : u32, } ", + r#"Struct { "MyStruct" { 0:0 0:30 } {} "" {} + Var { "foo" { 0:18 0:27 } {} "" {} } +}"#, + ); + test_describe_structure( + "union MyUnion { foo : u32, } ", + r#"Union { "MyUnion" { 0:0 0:28 } {} "" {} + Var { "foo" { 0:16 0:25 } {} "" {} } +}"#, + ); + + test_describe_structure("trait MyTrait { } ", r#"Trait { "MyTrait" { 0:0 0:17 } {} "" {} }"#); + test_describe_structure( + "trait MyTrait : Foo { fn xxx(); } ", + r#"Trait { "MyTrait" { 0:0 0:33 } {} "" {} + Function { "xxx" { 0:22 0:31 } {} "()" {} } +}"#, + ); + test_describe_structure( + "trait MyTrait : Foo { type N: fmt::Display; fn xxx(&self); const foo :u32 = 3; } ", + r#"Trait { "MyTrait" { 0:0 0:80 } {} "" {} + TypeAlias { "N" { 0:22 0:43 } {} "" {} } + Function { "xxx" { 0:44 0:58 } {} "(&self)" {} } + Var { "foo" { 0:59 0:78 } {} "" {} } +}"#, + ); + + /* FIXME: review + test_describe_structure("impl MyType { } ", r#"Impl { "MyType" { 0:0 0:15 } {} "" {} }"#); + test_describe_structure("impl MyTrait for MyType { } ", r#"Impl { "MyType.MyTrait" { 0:0 0:27 } {} "" {} }"#); + test_describe_structure("impl MyTrait { type N= fmt::Display; fn xx(){} const foo :u32 = 3; } ", +r#"Impl { "MyTrait" { 0:0 0:75 } {} "" {} + TypeAlias { "N" { 0:22 0:43 } {} "" {} } + Function { "xx" { 0:44 0:53 } {} "()" {} } + Var { "foo" { 0:54 0:73 } {} "" {} } +}"#); + */ + + test_describe_structure("use blah;", r#"Use { "blah" { 0:0 0:9 } {} "" {} }"#); + test_describe_structure("use blah as foo;", r#"Use { "blah as foo" { 0:0 0:16 } {} "" {} }"#); + // TODO: this is not printing the global path prefix, seems to be a limitation from libsyntax? + test_describe_structure("use ::blah::foo as myfoo;", r#"Use { "::blah::foo as myfoo" { 0:0 0:25 } {} "" {} }"#); + test_describe_structure("use ::blah::foo::*;", r#"Use { "::blah::foo::*" { 0:0 0:19 } {} "" {} }"#); + test_describe_structure("use blah::foo:: { One as OtherOne, self as Two };", r#"Use { "blah::foo::{ One as OtherOne, self as Two, }" { 0:0 0:49 } {} "" {} }"#); + + test_describe_structure("my_macro!(asf); ", ""); + + // test: visit_mac! visit method + test_describe_structure("fn foo() { my_macro!(asf); }", r#"Function { "foo" { 0:0 0:28 } {} "()" {} }"#); + + test_describe_structure("macro_rules! foo { (x => $e:expr) => (); }", r#""#); + // TODO: macro definitions, unfortunately can't get that info easily from syntax_syntex + // test_describe_structure("macro_rules! five_times { ($x:expr) => (5 * $x); }", + // r#"Macro { "foo" { 0:0 0:28 } {} "" {} }"#); + + // Test pub extern + test_describe_structure("pub extern crate my_crate;", r#"ExternCrate { "my_crate" { 0:0 0:26 } {} "" {} }"#); + + test_describe_structure( + "extern { fn ext(p : u32); }", + r#"Mod { "" { 0:0 0:27 } {} "" {} + Function { "ext" { 0:9 0:25 } {} "" {} } +}"#, + ); + test_describe_structure( + "extern { fn ext(p : u32); \n static extVar: u8; }", + r#"Mod { "" { 0:0 1:21 } {} "" {} + Function { "ext" { 0:9 0:25 } {} "" {} } + Var { "extVar" { 1:1 1:19 } {} "" {} } +}"#, + ); + + // Test with a lexer error, + // test_describe_structure("const xx : u32 = '", r#"Var { "xx" { 1 0 1 19 } {} {} {} }"#); +} diff --git a/src/token_writer.rs b/src/token_writer.rs index 188b9c7..3dabae1 100644 --- a/src/token_writer.rs +++ b/src/token_writer.rs @@ -1,131 +1,115 @@ -// Copyright 2015 Bruno Medeiros -// -// 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. - -use util::core::*; - -use std::result; -use std::fmt; - -pub use std::cell::{ RefCell , RefMut }; -pub use std::rc::{ Rc }; - -/// Write a parse structure into a serialized format -pub struct TokenWriter { - pub out : Rc>, -} - -impl fmt::Debug for TokenWriter { - - fn fmt(&self, fmt : &mut fmt::Formatter) -> fmt::Result { - fmt.write_str("[TokenWriter]") - } - -} - -impl TokenWriter { - - pub fn get_output(&self) -> RefMut { - self.out.borrow_mut() - } - - pub fn write_raw(&mut self, string : &str) -> result::Result<(), fmt::Error> { - self.get_output().write_str(string) - } - - pub fn write_string_token(&mut self, string : &str) -> result::Result<(), fmt::Error> { - try!(write_escaped_string(string, &mut* self.get_output())); - - self.get_output().write_char(' ') - } - - pub fn write_raw_token(&mut self, string : &str) -> Void { - - for ch in string.chars() { - if ch.is_whitespace() - || ch == '{' || ch == '}' - || ch == '(' || ch == ')' - || ch == '[' || ch == ']' - { - return Err("Cannot write raw token".into()); - } - } - - try!(self.get_output().write_str(string)); - try!(self.get_output().write_char(' ')); - - Ok(()) - } - -} - -#[test] -fn test__write_raw_token() { - - fn write_raw_token_toString(string : &str) -> GResult { - let outRc : Rc> = Rc::new(RefCell::new(String::new())); - - let result = TokenWriter { out: outRc.clone() }.write_raw_token(string); - match result { - Ok(_) => Ok(unwrap_Rc_RefCell(outRc)), - Err(error) => Err(error), - } - } - - assert_eq!(write_raw_token_toString("blah").ok().unwrap(), r#"blah "#); - write_raw_token_toString("bl ah").unwrap_err(); - write_raw_token_toString("bl{ah").unwrap_err(); -} - -/* ----------------- some parser/serialize utils ----------------- */ - -pub fn write_escaped_string(string : &str, out : &mut OUT) - -> fmt::Result -//pub fn write_string_token>(string : &str, out : &mut OUT) -// -> result::Result<(), ERR> -{ - - try!(out.write_char('"')); - - for ch in string.chars() { - - if ch == '"' || ch == '\\' { - try!(out.write_char('\\')); - } - try!(out.write_char(ch)); - - } - - try!(out.write_char('"')); - - Ok(()) -} - - -#[test] -fn test__write_escaped_string() { - - fn write_string_token_toString(string : &str) -> String { - let mut result = String::new(); - write_escaped_string(string, &mut result).unwrap(); - result - } - - assert_eq!(write_string_token_toString(""), r#""""#); - assert_eq!(write_string_token_toString("abc"), r#""abc""#); - assert_eq!(write_string_token_toString(r#"-"-"#), r#""-\"-""#); - assert_eq!(write_string_token_toString(r#"""#), r#""\"""#); - assert_eq!(write_string_token_toString(r#"\"#), r#""\\""#); - assert_eq!(write_string_token_toString(r#"--\"-"#), r#""--\\\"-""#); - assert_eq!(write_string_token_toString(r#"---\"#), r#""---\\""#); -} \ No newline at end of file +// Copyright 2015 Bruno Medeiros +// +// 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. + +use util::core::*; + +use std::fmt; +use std::result; + +pub use std::cell::{RefCell, RefMut}; +pub use std::rc::Rc; + +/// Write a parse structure into a serialized format +pub struct TokenWriter { + pub out: Rc>, +} + +impl fmt::Debug for TokenWriter { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.write_str("[TokenWriter]") + } +} + +impl TokenWriter { + pub fn get_output(&self) -> RefMut { + self.out.borrow_mut() + } + + pub fn write_raw(&mut self, string: &str) -> result::Result<(), fmt::Error> { + self.get_output().write_str(string) + } + + pub fn write_string_token(&mut self, string: &str) -> result::Result<(), fmt::Error> { + try!(write_escaped_string(string, &mut *self.get_output())); + + self.get_output().write_char(' ') + } + + pub fn write_raw_token(&mut self, string: &str) -> Void { + for ch in string.chars() { + if ch.is_whitespace() || ch == '{' || ch == '}' || ch == '(' || ch == ')' || ch == '[' || ch == ']' { + return Err("Cannot write raw token".into()); + } + } + + try!(self.get_output().write_str(string)); + try!(self.get_output().write_char(' ')); + + Ok(()) + } +} + +#[test] +fn test__write_raw_token() { + fn write_raw_token_toString(string: &str) -> GResult { + let outRc: Rc> = Rc::new(RefCell::new(String::new())); + + let result = TokenWriter { out: outRc.clone() }.write_raw_token(string); + match result { + Ok(_) => Ok(unwrap_Rc_RefCell(outRc)), + Err(error) => Err(error), + } + } + + assert_eq!(write_raw_token_toString("blah").ok().unwrap(), r#"blah "#); + write_raw_token_toString("bl ah").unwrap_err(); + write_raw_token_toString("bl{ah").unwrap_err(); +} + +/* ----------------- some parser/serialize utils ----------------- */ + +pub fn write_escaped_string(string: &str, out: &mut OUT) -> fmt::Result +//pub fn write_string_token>(string : &str, out : &mut OUT) +// -> result::Result<(), ERR> +{ + try!(out.write_char('"')); + + for ch in string.chars() { + if ch == '"' || ch == '\\' { + try!(out.write_char('\\')); + } + try!(out.write_char(ch)); + } + + try!(out.write_char('"')); + + Ok(()) +} + +#[test] +fn test__write_escaped_string() { + fn write_string_token_toString(string: &str) -> String { + let mut result = String::new(); + write_escaped_string(string, &mut result).unwrap(); + result + } + + assert_eq!(write_string_token_toString(""), r#""""#); + assert_eq!(write_string_token_toString("abc"), r#""abc""#); + assert_eq!(write_string_token_toString(r#"-"-"#), r#""-\"-""#); + assert_eq!(write_string_token_toString(r#"""#), r#""\"""#); + assert_eq!(write_string_token_toString(r#"\"#), r#""\\""#); + assert_eq!(write_string_token_toString(r#"--\"-"#), r#""--\\\"-""#); + assert_eq!(write_string_token_toString(r#"---\"#), r#""---\\""#); +} From 92afc1f58e545ffec02d07243db2e3e0511de3da Mon Sep 17 00:00:00 2001 From: Serhii Plyhun Date: Thu, 2 Aug 2018 18:04:08 +0200 Subject: [PATCH 3/7] Syntex update --- Cargo.lock | 400 +++++++++++++++++++++++++++------------ Cargo.toml | 5 +- src/lib.rs | 1 + src/parse_describe.rs | 15 +- src/source_model.rs | 10 +- src/structure_visitor.rs | 85 ++++----- 6 files changed, 338 insertions(+), 178 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8475a7a..4001010 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,33 +1,78 @@ [[package]] -name = "bitflags" -version = "0.9.1" +name = "arrayvec" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "bitflags" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "byteorder" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "cfg-if" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "dtoa" -version = "0.4.3" +name = "crossbeam-deque" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "extprim" -version = "1.6.0" +name = "crossbeam-epoch" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "either" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ena" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -45,19 +90,10 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "itoa" -version = "0.4.2" +name = "lazy_static" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "libc" version = "0.2.42" @@ -65,39 +101,56 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.3.9" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "log" -version = "0.4.3" +name = "memoffset" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "nodrop" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "num_cpus" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "num-traits" -version = "0.2.5" +name = "owning_ref" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "proc-macro2" -version = "0.4.8" +name = "parking_lot" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "quote" -version = "0.6.3" +name = "parking_lot_core" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -105,8 +158,9 @@ name = "rainicorn" version = "2.0.0" dependencies = [ "rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.60.0 (git+https://github.com/snuk182/syntex)", + "syntex_pos 0.60.0 (git+https://github.com/snuk182/syntex)", + "syntex_syntax 0.60.0 (git+https://github.com/snuk182/syntex)", ] [[package]] @@ -120,124 +174,207 @@ dependencies = [ ] [[package]] -name = "rustc_version" -version = "0.2.2" +name = "redox_syscall" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_termios" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rustdt_util" -version = "0.2.3" +name = "rustc-hash" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "semver" -version = "0.9.0" +name = "rustc-rayon" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-rayon-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "semver-parser" -version = "0.7.0" +name = "rustc-serialize" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "serde" -version = "1.0.70" +name = "rustdt_util" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "scoped-tls" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "scopeguard" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "smallvec" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "serde_derive" -version = "1.0.70" +name = "stable_deref_trait" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "syntex_arena" +version = "0.60.0" +source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" dependencies = [ - "proc-macro2 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_data_structures 0.60.0 (git+https://github.com/snuk182/syntex)", ] [[package]] -name = "serde_json" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "syntex_cratesio_shim" +version = "0.60.0" +source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" dependencies = [ - "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "syn" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "syntex_data_structures" +version = "0.60.0" +source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" dependencies = [ - "proc-macro2 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_cratesio_shim 0.60.0 (git+https://github.com/snuk182/syntex)", ] [[package]] name = "syntex_errors" -version = "0.59.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.60.0" +source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_data_structures 0.60.0 (git+https://github.com/snuk182/syntex)", + "syntex_pos 0.60.0 (git+https://github.com/snuk182/syntex)", + "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syntex_pos" -version = "0.59.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.60.0" +source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" dependencies = [ - "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_arena 0.60.0 (git+https://github.com/snuk182/syntex)", + "syntex_data_structures 0.60.0 (git+https://github.com/snuk182/syntex)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syntex_syntax" -version = "0.59.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.60.0" +source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" dependencies = [ - "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "extprim 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_data_structures 0.60.0 (git+https://github.com/snuk182/syntex)", + "syntex_errors 0.60.0 (git+https://github.com/snuk182/syntex)", + "syntex_pos 0.60.0 (git+https://github.com/snuk182/syntex)", + "syntex_target 0.0.0 (git+https://github.com/snuk182/syntex)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "term" -version = "0.4.6" +name = "syntex_target" +version = "0.0.0" +source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_cratesio_shim 0.60.0 (git+https://github.com/snuk182/syntex)", +] + +[[package]] +name = "termcolor" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "termion" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-width" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "winapi" -version = "0.2.8" +name = "unreachable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "void" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -249,11 +386,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -264,38 +396,62 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wincolor" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] -"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" +"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" +"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" +"checksum byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8389c509ec62b9fe8eca58c502a0acaf017737355615243496cde4994f8fa4f9" "checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" -"checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" -"checksum extprim 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "054bc2552b3f66fa8097e29e47255bfff583c08e737a67cbbb54b817ddaa5206" +"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" +"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" +"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" +"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" +"checksum ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dc8393b3c7352f94092497f6b52019643e493b6b890eb417cdb7c46117e621" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fb497c35d362b6a331cfd94956a07fc2c78a4604cdbee844a81170386b996dd3" "checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" -"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "61bd98ae7f7b754bc53dca7d44b604f733c6bba044ea6f41bc8d89272d8161d2" -"checksum num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "630de1ef5cc79d0cdd78b7e33b81f083cbfe90de0f4b2b2f07f905867c70e9fe" -"checksum proc-macro2 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c65b1ea15bb859d922cade2d1765b4b88beac339cbfad545ef2d2ef8c8215ee6" -"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" +"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" +"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" +"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" +"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" +"checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" +"checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" -"checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" +"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" +"checksum rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c6d5a683c6ba4ed37959097e88d71c9e8e26659a3cb5be8b389078e7ad45306" +"checksum rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40f06724db71e18d68b3b946fdf890ca8c921d9edccc1404fdfdb537b0d12649" +"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7cfffa8a89d8758be2dd5605c5fc62bce055af2491ebf3ce953d4d31512c59fd" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3adf19c07af6d186d91dae8927b83b0553d07ca56cbf7f2f32560455c91920" -"checksum serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "3525a779832b08693031b8ecfb0de81cd71cfd3812088fafe9a7496789572124" -"checksum serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c6908c7b925cd6c590358a4034de93dbddb20c45e1d021931459fd419bf0e2" -"checksum syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2beff8ebc3658f07512a413866875adddd20f4fd47b2a4e6c9da65cd281baaea" -"checksum syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3133289179676c9f5c5b2845bf5a2e127769f4889fcbada43035ef6bd662605e" -"checksum syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "30ab669fa003d208c681f874bbc76d91cc3d32550d16b5d9d2087cf477316470" -"checksum syntex_syntax 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03815b9f04d95828770d9c974aa39c6e1f6ef3114eb77a3ce09008a0d15dd142" -"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" +"checksum scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28" +"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" +"checksum smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "26df3bb03ca5eac2e64192b723d51f56c1b1e0860e7c766281f4598f181acdc8" +"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" +"checksum syntex_arena 0.60.0 (git+https://github.com/snuk182/syntex)" = "" +"checksum syntex_cratesio_shim 0.60.0 (git+https://github.com/snuk182/syntex)" = "" +"checksum syntex_data_structures 0.60.0 (git+https://github.com/snuk182/syntex)" = "" +"checksum syntex_errors 0.60.0 (git+https://github.com/snuk182/syntex)" = "" +"checksum syntex_pos 0.60.0 (git+https://github.com/snuk182/syntex)" = "" +"checksum syntex_syntax 0.60.0 (git+https://github.com/snuk182/syntex)" = "" +"checksum syntex_target 0.0.0 (git+https://github.com/snuk182/syntex)" = "" +"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" diff --git a/Cargo.toml b/Cargo.toml index 82ee0ee..7e306f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,9 @@ version = "2.0.0" autobins = false [dependencies] -syntex_errors = "^0.59" -syntex_syntax = "^0.59" +syntex_errors = { git = "https://github.com/snuk182/syntex" } +syntex_syntax = { git = "https://github.com/snuk182/syntex" } +syntex_pos = { git = "https://github.com/snuk182/syntex" } rustdt_util ="0.2.3" [[bin]] diff --git a/src/lib.rs b/src/lib.rs index 486480a..e1bc58c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ extern crate rustdt_util as util; extern crate syntex_errors; extern crate syntex_syntax; +extern crate syntex_pos; pub mod parse_describe; pub mod source_model; diff --git a/src/parse_describe.rs b/src/parse_describe.rs index e099f4c..d2f77e8 100644 --- a/src/parse_describe.rs +++ b/src/parse_describe.rs @@ -17,12 +17,13 @@ use util::core::*; use util::string::*; use syntex_errors::emitter; -use syntex_errors::{DiagnosticBuilder, Handler, Level}; +use syntex_errors::{DiagnosticBuilder, Handler, Level, DiagnosticId}; use syntex_syntax::codemap::{self, CodeMap, FilePathMapping, MultiSpan}; use syntex_syntax::parse::{self, ParseSess}; use syntex_syntax::syntax::ast; use syntex_syntax::tokenstream::TokenStream; use syntex_syntax::visit; +use syntex_pos::FileName; use std::boxed::Box; use std::path::Path; @@ -151,10 +152,9 @@ fn parse_crate<'a>(source: &str, codemap: Rc, messages: Arc(source: &str, sess: &'a ParseSess) -> parse::PResult<'a, ast::Crate> { let source = source.to_string(); let name = "_file_module_".to_string(); - let filemap = sess.codemap().new_filemap(name, source); - + let tts = { - let mut p1 = parse::filemap_to_parser(sess, filemap); + let mut p1 = parse::new_parser_from_source_str(sess, FileName::Real(name.into()), source); p1.parse_all_token_trees()?.into_iter().map(|tt| tt.into()).collect::>() }; @@ -183,7 +183,10 @@ impl emitter::Emitter for MessagesHandler { fn emit(&mut self, db: &DiagnosticBuilder) { let msg = db.message(); let msg = msg.as_str(); - let code: Option<&String> = db.code.as_ref(); + let code: Option<&String> = db.code.as_ref().map(|c| match c { + DiagnosticId::Error(ref str) => str, + DiagnosticId::Lint(ref str) => str, + }); let lvl: Level = db.level; let multispan: &MultiSpan = &db.span; @@ -207,7 +210,7 @@ fn level_to_status_level(lvl: Level) -> Severity { Level::Bug => panic!("Level::BUG"), Level::Cancelled => panic!("Level::CANCELLED"), Level::Help | Level::Note => Severity::INFO, - Level::Warning => Severity::WARNING, + Level::Warning | Level::FailureNote => Severity::WARNING, Level::Error | Level::Fatal => Severity::ERROR, } } diff --git a/src/source_model.rs b/src/source_model.rs index e3e700d..0105895 100644 --- a/src/source_model.rs +++ b/src/source_model.rs @@ -30,8 +30,8 @@ pub struct SourceRange { impl SourceRange { pub fn new(codemap: &CodeMap, span: Span) -> SourceRange { - let startLoc = codemap.lookup_char_pos(span.lo); - let endLoc = codemap.lookup_char_pos(span.hi); + let startLoc = codemap.lookup_char_pos(span.lo()); + let endLoc = codemap.lookup_char_pos(span.hi()); SourceRange::from_loc(startLoc, endLoc) } @@ -91,7 +91,9 @@ pub enum StructureElementKind { ExternCrate, Mod, Use, - MacroDef, // FIXME: not actually created at the moment + MacroDef, + Existential, + TraitAlias, TypeAlias, } @@ -111,6 +113,8 @@ impl StructureElementKind { StructureElementKind::Use => "Use", StructureElementKind::MacroDef => "Macro", StructureElementKind::TypeAlias => "TypeAlias", + StructureElementKind::Existential => "Existential", + StructureElementKind::TraitAlias => "TraitAlias", } } } diff --git a/src/structure_visitor.rs b/src/structure_visitor.rs index 5b0fa14..1face09 100644 --- a/src/structure_visitor.rs +++ b/src/structure_visitor.rs @@ -96,7 +96,7 @@ impl<'ps> StructureVisitor<'ps> { /* ----------------- ----------------- */ - fn write_ItemUse(&mut self, vp: &ViewPath, span: Span) { + fn write_ItemUse(&mut self, tree: &UseTree) { use std::ops::Index; use syntex_syntax::ast; use syntex_syntax::print::pprust; @@ -108,43 +108,38 @@ impl<'ps> StructureVisitor<'ps> { outString.push_str(&pprust::path_to_string(path)); } - match &vp.node { - &ViewPathSimple(ref ident, ref path) => { - writePath(&mut useSpec, path); + match tree.kind { + UseTreeKind::Simple(ref ident, _ , _) => { + writePath(&mut useSpec, &tree.prefix); - let path: &ast::Path = path; + let path: &ast::Path = &tree.prefix; if path.segments.len() == 0 { return; } let lastSegment = path.segments.index(path.segments.len() - 1); - if &lastSegment.identifier != ident { - useSpec.push_str(&" as "); - useSpec.push_str(&*ident.name.as_str()); + if let Some(ident) = ident { + if &lastSegment.ident != ident { + useSpec.push_str(&" as "); + useSpec.push_str(&*ident.name.as_str()); + } } } - &ViewPathGlob(ref path) => { - useSpec.push_str(&pprust::path_to_string(path)); + UseTreeKind::Glob => { + useSpec.push_str(&pprust::path_to_string(&tree.prefix)); useSpec.push_str(&"::*"); } - &ViewPathList(ref path, ref pathListItem) => { - writePath(&mut useSpec, path); + UseTreeKind::Nested(ref trees) => { + writePath(&mut useSpec, &tree.prefix); useSpec.push_str("::{ "); - for pitem in pathListItem { - let pitem: PathListItem_ = pitem.node; - - useSpec.push_str(&*pitem.name.name.as_str()); - if let Some(rename) = pitem.rename { - useSpec.push_str(" as "); - useSpec.push_str(&*rename.name.as_str()); - } - useSpec.push_str(", "); + for treenode in trees { + self.write_ItemUse(&treenode.0); } useSpec.push_str("}"); } } - self.write_element_handled(&useSpec, kind, SourceRange::new(self.codemap, span), "".to_string(), &|_: &mut Self| {}) + self.write_element_handled(&useSpec, kind, SourceRange::new(self.codemap, tree.span), "".to_string(), &|_: &mut Self| {}) } fn get_type_desc_from_fndecl(&mut self, fd: &FnDecl) -> String { @@ -200,8 +195,8 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { fn visit_name(&mut self, _span: Span, _name: Name) { // Nothing to do. } - fn visit_ident(&mut self, span: Span, ident: Ident) { - walk_ident(self, span, ident); + fn visit_ident(&mut self, ident: Ident) { + walk_ident(self, ident); } fn visit_mod(&mut self, m: &'v Mod, _span: Span, _attrs: &[Attribute], _nodeid: NodeId) { @@ -223,11 +218,17 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { }; match item.node { + ItemKind::Existential(ref _bounds, ref _generics) => { + kind = StructureElementKind::Existential; + } + ItemKind::TraitAlias(ref _generics, ref _bounds) => { + kind = StructureElementKind::TraitAlias; + } ItemKind::ExternCrate(_opt_name) => { kind = StructureElementKind::ExternCrate; } ItemKind::Use(ref vp) => { - self.write_ItemUse(vp, item.span); + self.write_ItemUse(vp); return; } ItemKind::Static(ref typ, _, ref _expr) | ItemKind::Const(ref typ, ref _expr) => { @@ -237,8 +238,8 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { self.write_element(item.ident, StructureElementKind::Var, item.span, type_desc, noop_walkFn); return; } - ItemKind::Fn(ref declaration, unsafety, constness, abi, ref generics, ref body) => { - self.visit_fn(FnKind::ItemFn(item.ident, generics, unsafety, constness, abi, &item.vis, body), declaration, item.span, item.id); + ItemKind::Fn(ref declaration, header, ref _generics, ref body) => { + self.visit_fn(FnKind::ItemFn(item.ident, header, &item.vis, body), declaration, item.span, item.id); return; } ItemKind::Mod(ref _module) => { @@ -253,9 +254,6 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { ItemKind::Enum(ref _enum_definition, ref _type_parameters) => { kind = StructureElementKind::Enum; } - ItemKind::DefaultImpl(_, ref _trait_ref) => { - kind = StructureElementKind::Impl; - } ItemKind::Impl(_, _, ref _type_parameters, _, ref _opt_trait_reference, ref _typ, ref _impl_items) => { kind = StructureElementKind::Impl; } @@ -270,7 +268,7 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { walk_item(self, item); return; } - ItemKind::Trait(_, ref _generics, ref _bounds, ref _methods) => { + ItemKind::Trait(_, _, ref _generics, ref _bounds, ref _methods) => { kind = StructureElementKind::Trait; } ItemKind::Mac(ref mac) => { @@ -365,6 +363,9 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { walk_impl_item(self, ii); return; } + ImplItemKind::Existential(_) => { + kind = StructureElementKind::Existential; + } } self.write_element_TODO(ii.ident, kind, ii.span, |_self: &mut Self| { @@ -381,7 +382,7 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { FnKind::Method(_ident, ref _MethodSig, _option, _b) => { ident = _ident; } - FnKind::ItemFn(_ident, ref _Generics, _Unsafety, _Constness, _Abi, _Visibility, _b) => { + FnKind::ItemFn(_ident, FnHeader { asyncness: _Asyncness, unsafety: _Unsafety, constness: _Constness, abi: _Abi }, _Visibility, _b) => { ident = _ident; } FnKind::Closure(_) => { @@ -404,6 +405,12 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { ForeignItemKind::Static(ref _typ, _) => { kind = StructureElementKind::Var; } + ForeignItemKind::Ty => { + kind = StructureElementKind::TypeAlias; + } + ForeignItemKind::Macro(_) => { + kind = StructureElementKind::MacroDef; + } } self.write_element_TODO(foreign_item.ident, kind, foreign_item.span, |_self: &mut Self| { @@ -414,9 +421,6 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { fn visit_trait_ref(&mut self, t: &'v TraitRef) { walk_trait_ref(self, t) } - fn visit_ty_param_bound(&mut self, bounds: &'v TyParamBound) { - walk_ty_param_bound(self, bounds) - } fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: &'v TraitBoundModifier) { walk_poly_trait_ref(self, t, m) } @@ -424,10 +428,7 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { fn visit_lifetime(&mut self, lifetime: &'v Lifetime) { walk_lifetime(self, lifetime) } - fn visit_lifetime_def(&mut self, lifetime: &'v LifetimeDef) { - walk_lifetime_def(self, lifetime) - } - + fn visit_local(&mut self, l: &'v Local) { walk_local(self, l) } @@ -460,15 +461,9 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { fn visit_path(&mut self, path: &'v Path, _id: NodeId) { walk_path(self, path) } - fn visit_path_list_item(&mut self, prefix: &'v Path, item: &'v PathListItem) { - walk_path_list_item(self, prefix, item) - } fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) { walk_path_segment(self, path_span, path_segment) } - fn visit_path_parameters(&mut self, path_span: Span, path_parameters: &'v PathParameters) { - walk_path_parameters(self, path_span, path_parameters) - } fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding) { walk_assoc_type_binding(self, type_binding) } From 36dd3f002f399fc25d2cdd1d3ad1025026d31076 Mon Sep 17 00:00:00 2001 From: Serhii Plyhun Date: Thu, 2 Aug 2018 19:09:06 +0200 Subject: [PATCH 4/7] Globals usage fixed --- src/parse_describe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parse_describe.rs b/src/parse_describe.rs index d2f77e8..6d8c170 100644 --- a/src/parse_describe.rs +++ b/src/parse_describe.rs @@ -64,7 +64,7 @@ pub fn parse_crate_with_messages(source: &str) -> (Vec, Vec Date: Fri, 24 Aug 2018 20:57:16 +0200 Subject: [PATCH 5/7] Delete Cargo.lock --- Cargo.lock | 457 ----------------------------------------------------- 1 file changed, 457 deletions(-) delete mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 4001010..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,457 +0,0 @@ -[[package]] -name = "arrayvec" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "atty" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bitflags" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "byteorder" -version = "1.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "crossbeam-deque" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-utils" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "either" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ena" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "memoffset" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "nodrop" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "num_cpus" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "owning_ref" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot_core" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rainicorn" -version = "2.0.0" -dependencies = [ - "rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_errors 0.60.0 (git+https://github.com/snuk182/syntex)", - "syntex_pos 0.60.0 (git+https://github.com/snuk182/syntex)", - "syntex_syntax 0.60.0 (git+https://github.com/snuk182/syntex)", -] - -[[package]] -name = "rand" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "redox_syscall" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-hash" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-rayon" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-rayon-core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustdt_util" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scoped-tls" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "smallvec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stable_deref_trait" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syntex_arena" -version = "0.60.0" -source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" -dependencies = [ - "syntex_data_structures 0.60.0 (git+https://github.com/snuk182/syntex)", -] - -[[package]] -name = "syntex_cratesio_shim" -version = "0.60.0" -source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" -dependencies = [ - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syntex_data_structures" -version = "0.60.0" -source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" -dependencies = [ - "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_cratesio_shim 0.60.0 (git+https://github.com/snuk182/syntex)", -] - -[[package]] -name = "syntex_errors" -version = "0.60.0" -source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" -dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_data_structures 0.60.0 (git+https://github.com/snuk182/syntex)", - "syntex_pos 0.60.0 (git+https://github.com/snuk182/syntex)", - "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syntex_pos" -version = "0.60.0" -source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" -dependencies = [ - "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_arena 0.60.0 (git+https://github.com/snuk182/syntex)", - "syntex_data_structures 0.60.0 (git+https://github.com/snuk182/syntex)", - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syntex_syntax" -version = "0.60.0" -source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" -dependencies = [ - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_data_structures 0.60.0 (git+https://github.com/snuk182/syntex)", - "syntex_errors 0.60.0 (git+https://github.com/snuk182/syntex)", - "syntex_pos 0.60.0 (git+https://github.com/snuk182/syntex)", - "syntex_target 0.0.0 (git+https://github.com/snuk182/syntex)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syntex_target" -version = "0.0.0" -source = "git+https://github.com/snuk182/syntex#0bfd2106be391a90c9cc58b5f24f0652abcc4307" -dependencies = [ - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_cratesio_shim 0.60.0 (git+https://github.com/snuk182/syntex)", -] - -[[package]] -name = "termcolor" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "termion" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-width" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wincolor" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" -"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" -"checksum byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8389c509ec62b9fe8eca58c502a0acaf017737355615243496cde4994f8fa4f9" -"checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" -"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" -"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" -"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" -"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" -"checksum ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dc8393b3c7352f94092497f6b52019643e493b6b890eb417cdb7c46117e621" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fb497c35d362b6a331cfd94956a07fc2c78a4604cdbee844a81170386b996dd3" -"checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" -"checksum log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "61bd98ae7f7b754bc53dca7d44b604f733c6bba044ea6f41bc8d89272d8161d2" -"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" -"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" -"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" -"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" -"checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" -"checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" -"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" -"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" -"checksum rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c6d5a683c6ba4ed37959097e88d71c9e8e26659a3cb5be8b389078e7ad45306" -"checksum rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40f06724db71e18d68b3b946fdf890ca8c921d9edccc1404fdfdb537b0d12649" -"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -"checksum rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7cfffa8a89d8758be2dd5605c5fc62bce055af2491ebf3ce953d4d31512c59fd" -"checksum scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28" -"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "26df3bb03ca5eac2e64192b723d51f56c1b1e0860e7c766281f4598f181acdc8" -"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" -"checksum syntex_arena 0.60.0 (git+https://github.com/snuk182/syntex)" = "" -"checksum syntex_cratesio_shim 0.60.0 (git+https://github.com/snuk182/syntex)" = "" -"checksum syntex_data_structures 0.60.0 (git+https://github.com/snuk182/syntex)" = "" -"checksum syntex_errors 0.60.0 (git+https://github.com/snuk182/syntex)" = "" -"checksum syntex_pos 0.60.0 (git+https://github.com/snuk182/syntex)" = "" -"checksum syntex_syntax 0.60.0 (git+https://github.com/snuk182/syntex)" = "" -"checksum syntex_target 0.0.0 (git+https://github.com/snuk182/syntex)" = "" -"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83" -"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" From 13ddf2831ab284682cfad96d53942e51bbb6b831 Mon Sep 17 00:00:00 2001 From: Serhii Plyhun Date: Thu, 7 Nov 2019 15:47:30 +0100 Subject: [PATCH 6/7] rustc 1.40 --- Cargo.lock | 655 ++++++++++++++++++++ Cargo.toml | 40 +- src/lib.rs | 23 +- src/parse_describe.rs | 846 +++++++++++++------------- src/source_model.rs | 260 ++++---- src/structure_visitor.rs | 1228 +++++++++++++++++++------------------- src/token_writer.rs | 230 +++---- 7 files changed, 1976 insertions(+), 1306 deletions(-) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..62ad2a3 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,655 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "annotate-snippets" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "arena" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +dependencies = [ + "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-queue" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "either" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ena" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "getrandom" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "graphviz" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" + +[[package]] +name = "hermit-abi" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "indexmap" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "itertools" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "jobserver" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.65" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lock_api" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "memoffset" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num_cpus" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro2" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rainicorn" +version = "3.0.0" +dependencies = [ + "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "rustc_errors 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syntax 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "syntax_pos 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc-hash" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-rayon" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-rayon-core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-rayon-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.11.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_data_structures" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "graphviz 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-rayon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-rayon-core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_index 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_errors" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +dependencies = [ + "annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "syntax_pos 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_index" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +dependencies = [ + "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_lexer" +version = "0.1.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +dependencies = [ + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_macros" +version = "0.1.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +dependencies = [ + "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_target" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "rustc_index 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "syntax_pos 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustdt_util" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serialize" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +dependencies = [ + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "smallvec" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "smallvec" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "stable_deref_trait" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "syn" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "synstructure" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntax" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "rustc_errors 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "rustc_index 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "rustc_lexer 0.1.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "rustc_target 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntax_pos 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", +] + +[[package]] +name = "syntax_pos" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +dependencies = [ + "arena 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "rustc_index 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "rustc_macros 0.1.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "term_size" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termcolor" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-width" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wasi" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wincolor" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[metadata] +"checksum annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7021ce4924a3f25f802b2cccd1af585e39ea1a363a1aa2e72afe54b67a3a7a7" +"checksum arena 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +"checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" +"checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" +"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" +"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +"checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" +"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +"checksum ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36" +"checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" +"checksum graphviz 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" +"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" +"checksum itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "87fa75c9dea7b07be3138c49abbb83fd4bea199b5cdc76f9804458edc5da0d6e" +"checksum jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" +"checksum memoffset 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a85c1a8c329f11437034d7313dca647c79096523533a1c79e86f1d0f657c7cc" +"checksum num_cpus 1.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "155394f924cdddf08149da25bfb932d226b4a593ca7468b08191ff6335941af5" +"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" +"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" +"checksum rustc-rayon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f32767f90d938f1b7199a174ef249ae1924f6e5bbdb9d112fea141e016f25b3a" +"checksum rustc-rayon-core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea2427831f0053ea3ea73559c8eabd893133a51b251d142bacee53c62a288cb3" +"checksum rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum rustc_errors 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum rustc_index 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum rustc_lexer 0.1.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum rustc_macros 0.1.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum rustc_target 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7cfffa8a89d8758be2dd5605c5fc62bce055af2491ebf3ce953d4d31512c59fd" +"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +"checksum serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +"checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" +"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" +"checksum syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7bedb3320d0f3035594b0b723c8a28d7d336a3eda3881db79e61d676fb644c" +"checksum synstructure 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "575be94ccb86e8da37efb894a87e2b660be299b41d8ef347f9d6d79fbe61b1ba" +"checksum syntax 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum syntax_pos 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" +"checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" +"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" +"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" diff --git a/Cargo.toml b/Cargo.toml index 7e306f1..dcc97bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,21 @@ -[package] -name = "rainicorn" -version = "2.0.0" -autobins = false - -[dependencies] -syntex_errors = { git = "https://github.com/snuk182/syntex" } -syntex_syntax = { git = "https://github.com/snuk182/syntex" } -syntex_pos = { git = "https://github.com/snuk182/syntex" } -rustdt_util ="0.2.3" - -[[bin]] -name = "parse_describe" -path = "src/main.rs" -test = false - -[lib] -name = "rainicorn" -path = "src/lib.rs" +[package] +name = "rainicorn" +version = "3.0.0" +autobins = false +edition = "2018" + +[dependencies] +rustc_errors = { git = "https://github.com/snuk182/rustc-syntax-tools" } +rustc_data_structures = { git = "https://github.com/snuk182/rustc-syntax-tools" } +syntax = { git = "https://github.com/snuk182/rustc-syntax-tools" } +syntax_pos = { git = "https://github.com/snuk182/rustc-syntax-tools" } +rustdt_util ="0.2.3" + +[[bin]] +name = "parse_describe" +path = "src/main.rs" +test = false + +[lib] +name = "rainicorn" +path = "src/lib.rs" diff --git a/src/lib.rs b/src/lib.rs index e1bc58c..53c81f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,12 @@ -#![allow(non_snake_case)] - -extern crate rustdt_util as util; -extern crate syntex_errors; -extern crate syntex_syntax; -extern crate syntex_pos; - -pub mod parse_describe; -pub mod source_model; -pub mod structure_visitor; -pub mod token_writer; +#![allow(non_snake_case)] + +use rustdt_util as util; +use rustc_errors as syntex_errors; +use rustc_data_structures; +use syntax as syntex_syntax; +use syntax_pos as syntex_pos; + +pub mod parse_describe; +pub mod source_model; +pub mod structure_visitor; +pub mod token_writer; diff --git a/src/parse_describe.rs b/src/parse_describe.rs index 6d8c170..39fa00e 100644 --- a/src/parse_describe.rs +++ b/src/parse_describe.rs @@ -1,418 +1,428 @@ -// Copyright 2015 Bruno Medeiros -// -// 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. - -use source_model::*; -use util::core::*; -use util::string::*; - -use syntex_errors::emitter; -use syntex_errors::{DiagnosticBuilder, Handler, Level, DiagnosticId}; -use syntex_syntax::codemap::{self, CodeMap, FilePathMapping, MultiSpan}; -use syntex_syntax::parse::{self, ParseSess}; -use syntex_syntax::syntax::ast; -use syntex_syntax::tokenstream::TokenStream; -use syntex_syntax::visit; -use syntex_pos::FileName; - -use std::boxed::Box; -use std::path::Path; - -use token_writer::TokenWriter; - -use std::cell::RefCell; -use std::env; -use std::fmt; -use std::io; -use std::io::Write; -use std::path::PathBuf; -use std::rc::*; - -/* ----------------- ----------------- */ - -pub fn parse_analysis_for_Stdout(source: &str) { - parse_analysis(source, StdoutWrite(io::stdout())).ok(); - println!(""); - io::stdout().flush().ok(); -} - -pub fn parse_analysis(source: &str, out: T) -> GResult { - let (messages, elements) = parse_crate_with_messages(source); - - let outRc = Rc::new(RefCell::new(out)); - try!(write_parse_analysis_do(messages, elements, outRc.clone())); - let res = unwrap_Rc_RefCell(outRc); - return Ok(res); -} - -use std::sync::{Arc, Mutex}; -use std::thread; - -pub fn parse_crate_with_messages(source: &str) -> (Vec, Vec) { - let messages = Arc::new(Mutex::new(vec![])); - let elements = { - let source = String::from(source); - let messages = messages.clone(); - - let worker_thread = thread::Builder::new().name("parser_thread".to_string()).spawn(move || ::syntex_syntax::with_globals(|| parse_crate_with_messages_do(&source, messages))).unwrap(); - - worker_thread.join().unwrap_or(vec![]) - }; - - let messages: Mutex> = Arc::try_unwrap(messages).ok().unwrap(); - let messages: Vec = messages.into_inner().unwrap(); - - return (messages, elements); -} - -pub fn parse_crate_with_messages_do(source: &str, messages: Arc>>) -> Vec { - use structure_visitor::StructureVisitor; - - let mut elements = vec![]; - - let fileLoader = Box::new(DummyFileLoader::new()); - let codemap = Rc::new(CodeMap::with_file_loader(fileLoader, FilePathMapping::empty())); - - let krate = parse_crate(source, codemap.clone(), messages.clone()); - - if let Some(krate) = krate { - let mut visitor: StructureVisitor = StructureVisitor::new(&codemap); - visit::walk_crate(&mut visitor, &krate); - - elements = visitor.elements; - } - return elements; -} - -/* ----------------- ----------------- */ - -use std::ffi::OsStr; - -/// A FileLoader that loads any file successfully -pub struct DummyFileLoader { - modName: &'static OsStr, -} - -impl DummyFileLoader { - fn new() -> DummyFileLoader { - DummyFileLoader { modName: OsStr::new("mod.rs") } - } -} - -impl codemap::FileLoader for DummyFileLoader { - fn file_exists(&self, path: &Path) -> bool { - return path.file_name() == Some(self.modName); - } - - fn abs_path(&self, path: &Path) -> Option { - if path.is_absolute() { - Some(path.to_path_buf()) - } else { - env::current_dir().ok().map(|cwd| cwd.join(path)) - } - } - - fn read_file(&self, _path: &Path) -> io::Result { - Ok(String::new()) - } -} - -struct MessagesHandler { - codemap: Rc, - messages: Arc>>, -} - -fn parse_crate<'a>(source: &str, codemap: Rc, messages: Arc>>) -> Option { - let emitter = MessagesHandler::new(codemap.clone(), messages.clone()); - - let handler = Handler::with_emitter(true, false, Box::new(emitter)); - let sess = ParseSess::with_span_handler(handler, codemap.clone()); - - let krate_result = parse_crate_do(source, &sess); - - return match krate_result { - Ok(_krate) => Some(_krate), - Err(mut db) => { - db.emit(); - None - } - }; -} - -pub fn parse_crate_do<'a>(source: &str, sess: &'a ParseSess) -> parse::PResult<'a, ast::Crate> { - let source = source.to_string(); - let name = "_file_module_".to_string(); - - let tts = { - let mut p1 = parse::new_parser_from_source_str(sess, FileName::Real(name.into()), source); - p1.parse_all_token_trees()?.into_iter().map(|tt| tt.into()).collect::>() - }; - - let mut parser = parse::parser::Parser::new(sess, TokenStream::concat(tts), None, false, false); - parser.parse_crate_mod() -} - -impl MessagesHandler { - fn new(codemap: Rc, messages: Arc>>) -> MessagesHandler { - MessagesHandler { codemap: codemap, messages: messages } - } - - fn write_message_handled(&mut self, sourcerange: Option, msg: &str, severity: Severity) { - let msg = SourceMessage { - severity: severity, - sourcerange: sourcerange, - message: String::from(msg), - }; - - let mut messages = self.messages.lock().unwrap(); - messages.push(msg); - } -} - -impl emitter::Emitter for MessagesHandler { - fn emit(&mut self, db: &DiagnosticBuilder) { - let msg = db.message(); - let msg = msg.as_str(); - let code: Option<&String> = db.code.as_ref().map(|c| match c { - DiagnosticId::Error(ref str) => str, - DiagnosticId::Lint(ref str) => str, - }); - let lvl: Level = db.level; - - let multispan: &MultiSpan = &db.span; - - if let Some(code) = code { - io::stderr().write_fmt(format_args!("Code: {}\n", code)).unwrap(); - panic!("What is code: Option<&str>??"); - } - - let sourceranges: Vec<_> = multispan.primary_spans().iter().map(|span| -> SourceRange { SourceRange::new(&self.codemap, *span) }).collect(); - - for sourcerange in sourceranges { - self.write_message_handled(Some(sourcerange), msg, level_to_status_level(lvl)); - } - } -} - -fn level_to_status_level(lvl: Level) -> Severity { - match lvl { - Level::PhaseFatal => panic!("Level::PhaseFatal"), - Level::Bug => panic!("Level::BUG"), - Level::Cancelled => panic!("Level::CANCELLED"), - Level::Help | Level::Note => Severity::INFO, - Level::Warning | Level::FailureNote => Severity::WARNING, - Level::Error | Level::Fatal => Severity::ERROR, - } -} - -impl MessagesHandler {} - -/* ----------------- describe writting ----------------- */ - -pub fn write_parse_analysis_do(messages: Vec, elements: Vec, out: Rc>) -> Void { - let mut tokenWriter = TokenWriter { out: out }; - - try!(tokenWriter.write_raw("RUST_PARSE_DESCRIBE 1.0 {\n")); - try!(write_parse_analysis_contents(messages, elements, &mut tokenWriter)); - try!(tokenWriter.write_raw("\n}")); - - Ok(()) -} - -pub fn write_parse_analysis_contents(messages: Vec, elements: Vec, tokenWriter: &mut TokenWriter) -> Void { - try!(tokenWriter.write_raw("MESSAGES {\n")); - for msg in messages { - try!(output_message(tokenWriter, msg.sourcerange, &msg.message, &msg.severity)); - } - try!(tokenWriter.write_raw("}\n")); - - for element in elements { - try!(write_structure_element(tokenWriter, &element, 0)); - } - - Ok(()) -} - -fn output_message(tokenWriter: &mut TokenWriter, opt_sr: Option, msg: &str, lvl: &Severity) -> Void { - try!(tokenWriter.write_raw("{ ")); - - try!(output_Level(&lvl, tokenWriter)); - - try!(output_opt_SourceRange(&opt_sr, tokenWriter)); - - try!(tokenWriter.write_string_token(msg)); - - try!(tokenWriter.write_raw("}\n")); - - Ok(()) -} - -pub fn output_Level(lvl: &Severity, writer: &mut TokenWriter) -> Void { - try!(writer.write_raw_token(lvl.to_string())); - - Ok(()) -} - -pub fn output_SourceRange(sr: &SourceRange, tw: &mut TokenWriter) -> Void { - try!(tw.write_raw("{ ")); - { - let mut out = tw.get_output(); - try!(out.write_fmt(format_args!("{}:{} {}:{} ", sr.start_pos.line - 1, sr.start_pos.col.0, sr.end_pos.line - 1, sr.end_pos.col.0,))); - } - try!(tw.write_raw("}")); - - Ok(()) -} - -pub fn output_opt_SourceRange(sr: &Option, writer: &mut TokenWriter) -> Void { - match sr { - &None => try!(writer.write_raw("{ }")), - &Some(ref sr) => try!(output_SourceRange(sr, writer)), - } - - try!(writer.write_raw(" ")); - - Ok(()) -} - -pub fn write_indent(tokenWriter: &mut TokenWriter, level: u32) -> Void { - try!(writeNTimes(&mut *tokenWriter.get_output(), ' ', level * 2)); - Ok(()) -} - -pub fn write_structure_element(tw: &mut TokenWriter, element: &StructureElement, level: u32) -> Void { - try!(tw.write_raw_token(element.kind.to_string())); - - try!(tw.write_raw("{ ")); - - try!(tw.write_string_token(&element.name)); - - try!(output_SourceRange(&element.sourcerange, tw)); - - try!(tw.get_output().write_str(" {}")); // name source range, Not Supported - - try!(tw.get_output().write_str(" ")); - try!(tw.write_string_token(&element.type_desc)); - - try!(tw.get_output().write_str("{}")); // attribs, Not Supported - - if element.children.is_empty() { - try!(tw.get_output().write_str(" ")); - } else { - let level = level + 1; - - for child in &element.children { - try!(tw.get_output().write_str("\n")); - try!(write_indent(tw, level)); - try!(write_structure_element(tw, child, level)); - } - - try!(tw.get_output().write_str("\n")); - try!(write_indent(tw, level - 1)); - } - - try!(tw.get_output().write_str("}")); - - Ok(()) -} - -#[cfg(test)] -mod parse_describe_tests { - - use parse_describe::*; - use source_model::*; - use std::cell::RefCell; - use std::rc::Rc; - use token_writer::TokenWriter; - use util; - use util::core::*; - use util::tests::check_equal; - - fn test_write_structure_element(name: &str, kind: StructureElementKind, sr: SourceRange, type_desc: String, expected: &str) { - let stringRc = Rc::new(RefCell::new(String::new())); - { - let name = String::from(name); - let element = StructureElement { - name: name, - kind: kind, - sourcerange: sr, - type_desc: type_desc, - children: vec![], - }; - let mut tw = TokenWriter { out: stringRc.clone() }; - - write_structure_element(&mut tw, &element, 0).ok(); - } - - assert_eq!(unwrap_Rc_RefCell(stringRc).trim(), expected); - } - - #[test] - fn write_structure_element__tests() { - test_write_structure_element("blah", StructureElementKind::Var, source_range(1, 0, 2, 5), "desc".to_string(), r#"Var { "blah" { 0:0 1:5 } {} "desc" {} }"#); - } - - #[test] - fn parse_analysis__tests() { - test_parse_analysis("", ""); - - test_parse_analysis(" #blah ", r#"{ ERROR { 0:2 0:6 } "expected `[`, found `blah`" }"#); - - test_parse_analysis( - "fn foo(\n blah", - r#" -{ ERROR { 1:6 1:6 } "this file contains an un-closed delimiter" } -{ ERROR { 1:6 1:6 } "expected one of `:` or `@`, found `)`" } -{ ERROR { 1:6 1:6 } "expected one of `->`, `where`, or `{`, found ``" } -"#, - ); - - // Test a lexer panic - test_parse_analysis("const a = '", r#"{ ERROR { 0:10 0:11 } "character literal may only contain one codepoint: '" }"#); - - // test `?` syntax shorthand for try: - test_parse_analysis("fn foo() { 123? }", &("}\n".to_string() + r#"Function { "foo" { 0:0 0:17 } {} "()" {}"#)); - } - - fn test_parse_analysis(source: &str, expected_msgs: &str) { - let result = parse_analysis(source, String::new()).ok().unwrap(); - let mut result: &str = &result; - - result = assert_surrounding_string("RUST_PARSE_DESCRIBE 1.0 {", result, "}"); - - result = assert_starts_with("MESSAGES {", result.trim()); - expected_msgs.replace("\r\n", "\n"); - result = assert_starts_with(expected_msgs.trim(), result.trim()); - check_equal(result.trim(), "}"); - } - - fn assert_surrounding_string<'a>(start: &str, string: &'a str, end: &str) -> &'a str { - let mut string: &str = string; - - string = assert_starts_with(start, string); - string = assert_ends_with(string, end); - - return string; - } - - fn assert_starts_with<'a>(start: &str, string: &'a str) -> &'a str { - util::tests::assert_starts_with(string, start); - return &string[start.len()..]; - } - - fn assert_ends_with<'a>(string: &'a str, end: &str) -> &'a str { - assert!(string.ends_with(end), "`{}` does not end with `{}`", string, end); - return &string[0..string.len() - end.len()]; - } - -} +// Copyright 2015 Bruno Medeiros +// +// 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. + +use crate::token_writer::TokenWriter; +use crate::source_model::*; + +use crate::util::core::*; +use crate::util::string::*; + +use crate::syntex_errors::emitter; +use crate::syntex_errors::{SourceMapperDyn, Diagnostic, Handler, Level, DiagnosticId}; +use crate::syntex_syntax::source_map::{self, SourceMap, FilePathMapping, MultiSpan}; +use crate::syntex_syntax::parse; +use crate::syntex_syntax::sess::ParseSess; +use crate::syntex_syntax::ast; +use crate::syntex_syntax::edition; +use crate::syntex_syntax::tokenstream::TokenStream; +use crate::syntex_syntax::visit; +use crate::syntex_pos::FileName; +use crate::rustc_data_structures::sync::Lrc; + +use std::boxed::Box; +use std::path::Path; + +use std::cell::RefCell; +use std::env; +use std::fmt; +use std::io; +use std::io::Write; +use std::path::PathBuf; +use std::rc::*; + +/* ----------------- ----------------- */ + +pub fn parse_analysis_for_Stdout(source: &str) { + parse_analysis(source, StdoutWrite(io::stdout())).ok(); + println!(""); + io::stdout().flush().ok(); +} + +pub fn parse_analysis(source: &str, out: T) -> GResult { + let (messages, elements) = parse_crate_with_messages(source); + + let outRc = Rc::new(RefCell::new(out)); + write_parse_analysis_do(messages, elements, outRc.clone())?; + let res = unwrap_Rc_RefCell(outRc); + return Ok(res); +} + +use std::sync::{Arc, Mutex}; +use std::thread; + +pub fn parse_crate_with_messages(source: &str) -> (Vec, Vec) { + let messages = Arc::new(Mutex::new(vec![])); + let elements = { + use crate::syntex_syntax::with_globals; + + let source = String::from(source); + let messages = messages.clone(); + + let worker_thread = thread::Builder::new().name("parser_thread".to_string()).spawn(move || with_globals(edition::DEFAULT_EDITION, || parse_crate_with_messages_do(&source, messages))).unwrap(); + + worker_thread.join().unwrap_or(vec![]) + }; + + let messages: Mutex> = Arc::try_unwrap(messages).ok().unwrap(); + let messages: Vec = messages.into_inner().unwrap(); + + return (messages, elements); +} + +pub fn parse_crate_with_messages_do(source: &str, messages: Arc>>) -> Vec { + use crate::structure_visitor::StructureVisitor; + + let mut elements = vec![]; + + let fileLoader = Box::new(DummyFileLoader::new()); + let codemap = Rc::new(SourceMap::with_file_loader(fileLoader, FilePathMapping::empty())); + + let krate = parse_crate(source, codemap.clone(), messages.clone()); + + if let Some(krate) = krate { + let mut visitor: StructureVisitor = StructureVisitor::new(&codemap); + visit::walk_crate(&mut visitor, &krate); + + elements = visitor.elements; + } + return elements; +} + +/* ----------------- ----------------- */ + +use std::ffi::OsStr; + +/// A FileLoader that loads any file successfully +pub struct DummyFileLoader { + modName: &'static OsStr, +} + +impl DummyFileLoader { + fn new() -> DummyFileLoader { + DummyFileLoader { modName: OsStr::new("mod.rs") } + } +} + +impl source_map::FileLoader for DummyFileLoader { + fn file_exists(&self, path: &Path) -> bool { + return path.file_name() == Some(self.modName); + } + + fn abs_path(&self, path: &Path) -> Option { + if path.is_absolute() { + Some(path.to_path_buf()) + } else { + env::current_dir().ok().map(|cwd| cwd.join(path)) + } + } + + fn read_file(&self, _path: &Path) -> io::Result { + Ok(String::new()) + } +} + +struct MessagesHandler { + codemap: Rc, + messages: Arc>>, +} + +fn parse_crate<'a>(source: &str, codemap: Rc, messages: Arc>>) -> Option { + let emitter = MessagesHandler::new(codemap.clone(), messages.clone()); + + let handler = Handler::with_emitter(true, None, Box::new(emitter)); + let sess = ParseSess::with_span_handler(handler, codemap.clone()); + + let krate_result = parse_crate_do(source, &sess); + + return match krate_result { + Ok(_krate) => Some(_krate), + Err(mut db) => { + db.emit(); + None + } + }; +} + +pub fn parse_crate_do<'a>(source: &str, sess: &'a ParseSess) -> parse::PResult<'a, ast::Crate> { + use std::iter::FromIterator; + + let source = source.to_string(); + let name = "_file_module_".to_string(); + + let tts = { + let mut p1 = parse::new_parser_from_source_str(sess, FileName::Real(name.into()), source); + p1.parse_all_token_trees()?.into_iter().map(|tt| tt.into()).collect::>() + }; + + let mut parser = parse::parser::Parser::new(sess, TokenStream::from_iter(tts), None, true, false, None); + parser.parse_crate_mod() +} + +impl MessagesHandler { + fn new(codemap: Rc, messages: Arc>>) -> MessagesHandler { + MessagesHandler { codemap: codemap, messages: messages } + } + + fn write_message_handled(&mut self, sourcerange: Option, msg: &str, severity: Severity) { + let msg = SourceMessage { + severity: severity, + sourcerange: sourcerange, + message: String::from(msg), + }; + + let mut messages = self.messages.lock().unwrap(); + messages.push(msg); + } +} + +impl emitter::Emitter for MessagesHandler { + fn emit_diagnostic(&mut self, db: &Diagnostic) { + let msg = db.message(); + let msg = msg.as_str(); + let code: Option<&String> = db.code.as_ref().map(|c| match c { + DiagnosticId::Error(ref str) => str, + DiagnosticId::Lint(ref str) => str, + }); + let lvl: Level = db.level; + + let multispan: &MultiSpan = &db.span; + + if let Some(code) = code { + io::stderr().write_fmt(format_args!("Code: {}\n", code)).unwrap(); + panic!("What is code: Option<&str>??"); + } + + let sourceranges: Vec<_> = multispan.primary_spans().iter().map(|span| -> SourceRange { SourceRange::new(self.codemap.as_ref(), *span) }).collect(); + + for sourcerange in sourceranges { + self.write_message_handled(Some(sourcerange), msg, level_to_status_level(lvl)); + } + } + + fn source_map(&self) -> Option<&Lrc> { + Some(&self.codemap) + } +} + +fn level_to_status_level(lvl: Level) -> Severity { + match lvl { + Level::Bug => panic!("Level::BUG"), + Level::Cancelled => panic!("Level::CANCELLED"), + Level::Help | Level::Note => Severity::INFO, + Level::Warning | Level::FailureNote => Severity::WARNING, + Level::Error | Level::Fatal => Severity::ERROR, + } +} + +impl MessagesHandler {} + +/* ----------------- describe writting ----------------- */ + +pub fn write_parse_analysis_do(messages: Vec, elements: Vec, out: Rc>) -> Void { + let mut tokenWriter = TokenWriter { out: out }; + + tokenWriter.write_raw("RUST_PARSE_DESCRIBE 1.0 {\n")?; + write_parse_analysis_contents(messages, elements, &mut tokenWriter)?; + tokenWriter.write_raw("\n}")?; + + Ok(()) +} + +pub fn write_parse_analysis_contents(messages: Vec, elements: Vec, tokenWriter: &mut TokenWriter) -> Void { + tokenWriter.write_raw("MESSAGES {\n")?; + for msg in messages { + output_message(tokenWriter, msg.sourcerange, &msg.message, &msg.severity)?; + } + tokenWriter.write_raw("}\n")?; + + for element in elements { + write_structure_element(tokenWriter, &element, 0)?; + } + + Ok(()) +} + +fn output_message(tokenWriter: &mut TokenWriter, opt_sr: Option, msg: &str, lvl: &Severity) -> Void { + tokenWriter.write_raw("{ ")?; + + output_Level(&lvl, tokenWriter)?; + + output_opt_SourceRange(&opt_sr, tokenWriter)?; + + tokenWriter.write_string_token(msg)?; + + tokenWriter.write_raw("}\n")?; + + Ok(()) +} + +pub fn output_Level(lvl: &Severity, writer: &mut TokenWriter) -> Void { + writer.write_raw_token(lvl.to_string())?; + + Ok(()) +} + +pub fn output_SourceRange(sr: &SourceRange, tw: &mut TokenWriter) -> Void { + tw.write_raw("{ ")?; + { + let mut out = tw.get_output(); + out.write_fmt(format_args!("{}:{} {}:{} ", sr.start_pos.line - 1, sr.start_pos.col.0, sr.end_pos.line - 1, sr.end_pos.col.0,))?; + } + tw.write_raw("}")?; + + Ok(()) +} + +pub fn output_opt_SourceRange(sr: &Option, writer: &mut TokenWriter) -> Void { + match sr { + &None => writer.write_raw("{ }")?, + &Some(ref sr) => output_SourceRange(sr, writer)?, + } + + writer.write_raw(" ")?; + + Ok(()) +} + +pub fn write_indent(tokenWriter: &mut TokenWriter, level: u32) -> Void { + writeNTimes(&mut *tokenWriter.get_output(), ' ', level * 2)?; + Ok(()) +} + +pub fn write_structure_element(tw: &mut TokenWriter, element: &StructureElement, level: u32) -> Void { + tw.write_raw_token(element.kind.to_string())?; + + tw.write_raw("{ ")?; + + tw.write_string_token(&element.name)?; + + output_SourceRange(&element.sourcerange, tw)?; + + tw.get_output().write_str(" {}")?; // name source range, Not Supported + + tw.get_output().write_str(" ")?; + tw.write_string_token(&element.type_desc)?; + + tw.get_output().write_str("{}")?; // attribs, Not Supported + + if element.children.is_empty() { + tw.get_output().write_str(" ")?; + } else { + let level = level + 1; + + for child in &element.children { + tw.get_output().write_str("\n")?; + write_indent(tw, level)?; + write_structure_element(tw, child, level)?; + } + + tw.get_output().write_str("\n")?; + write_indent(tw, level - 1)?; + } + + tw.get_output().write_str("}")?; + + Ok(()) +} + +#[cfg(test)] +mod parse_describe_tests { + use std::cell::RefCell; + use std::rc::Rc; + + use crate::parse_describe::*; + use crate::source_model::*; + use crate::token_writer::TokenWriter; + use crate::util; + use crate::util::core::*; + use crate::util::tests::check_equal; + + fn test_write_structure_element(name: &str, kind: StructureElementKind, sr: SourceRange, type_desc: String, expected: &str) { + let stringRc = Rc::new(RefCell::new(String::new())); + { + let name = String::from(name); + let element = StructureElement { + name: name, + kind: kind, + sourcerange: sr, + type_desc: type_desc, + children: vec![], + }; + let mut tw = TokenWriter { out: stringRc.clone() }; + + write_structure_element(&mut tw, &element, 0).ok(); + } + + assert_eq!(unwrap_Rc_RefCell(stringRc).trim(), expected); + } + + #[test] + fn write_structure_element__tests() { + test_write_structure_element("blah", StructureElementKind::Var, source_range(1, 0, 2, 5), "desc".to_string(), r#"Var { "blah" { 0:0 1:5 } {} "desc" {} }"#); + } + + #[test] + fn parse_analysis__tests() { + test_parse_analysis("", ""); + + test_parse_analysis(" #blah ", r#"{ ERROR { 0:2 0:6 } "expected `[`, found `blah`" }"#); + + test_parse_analysis( + "fn foo(\n blah", + r#" +{ ERROR { 1:6 1:6 } "this file contains an un-closed delimiter" } +{ ERROR { 1:6 1:6 } "expected one of `:` or `@`, found `)`" } +{ ERROR { 1:6 1:6 } "expected one of `->`, `where`, or `{`, found ``" } +"#, + ); + + // Test a lexer panic + test_parse_analysis("const a = '", r#"{ ERROR { 0:10 0:11 } "character literal may only contain one codepoint: '" }"#); + + // test `?` syntax shorthand for try: + test_parse_analysis("fn foo() { 123? }", &("}\n".to_string() + r#"Function { "foo" { 0:0 0:17 } {} "()" {}"#)); + } + + fn test_parse_analysis(source: &str, expected_msgs: &str) { + let result = parse_analysis(source, String::new()).ok().unwrap(); + let mut result: &str = &result; + + result = assert_surrounding_string("RUST_PARSE_DESCRIBE 1.0 {", result, "}"); + + result = assert_starts_with("MESSAGES {", result.trim()); + expected_msgs.replace("\r\n", "\n"); + result = assert_starts_with(expected_msgs.trim(), result.trim()); + check_equal(result.trim(), "}"); + } + + fn assert_surrounding_string<'a>(start: &str, string: &'a str, end: &str) -> &'a str { + let mut string: &str = string; + + string = assert_starts_with(start, string); + string = assert_ends_with(string, end); + + return string; + } + + fn assert_starts_with<'a>(start: &str, string: &'a str) -> &'a str { + util::tests::assert_starts_with(string, start); + return &string[start.len()..]; + } + + fn assert_ends_with<'a>(string: &'a str, end: &str) -> &'a str { + assert!(string.ends_with(end), "`{}` does not end with `{}`", string, end); + return &string[0..string.len() - end.len()]; + } + +} diff --git a/src/source_model.rs b/src/source_model.rs index 0105895..4461532 100644 --- a/src/source_model.rs +++ b/src/source_model.rs @@ -1,129 +1,131 @@ -// Copyright 2016 Bruno Medeiros -// -// 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. - -use syntex_syntax::codemap::{CharPos, CodeMap, Loc, Span}; - -#[derive(Debug, Clone, Copy)] -pub struct LineColumnPosition { - /// The (1-based) line number - pub line: usize, - /// The (0-based) column offset - pub col: CharPos, -} - -#[derive(Debug, Clone, Copy)] -pub struct SourceRange { - pub start_pos: LineColumnPosition, - pub end_pos: LineColumnPosition, -} - -impl SourceRange { - pub fn new(codemap: &CodeMap, span: Span) -> SourceRange { - let startLoc = codemap.lookup_char_pos(span.lo()); - let endLoc = codemap.lookup_char_pos(span.hi()); - - SourceRange::from_loc(startLoc, endLoc) - } - - pub fn from_loc(startLoc: Loc, endLoc: Loc) -> SourceRange { - SourceRange { - start_pos: LineColumnPosition { line: startLoc.line, col: startLoc.col }, - end_pos: LineColumnPosition { line: endLoc.line, col: endLoc.col }, - } - } -} - -pub fn source_range(start_line: usize, start_col: usize, end_line: usize, end_col: usize) -> SourceRange { - SourceRange { - start_pos: LineColumnPosition { line: start_line, col: CharPos(start_col) }, - end_pos: LineColumnPosition { line: end_line, col: CharPos(end_col) }, - } -} - -/* ----------------- ----------------- */ - -//use ::util::core::*; - -pub enum Severity { - INFO, - WARNING, - ERROR, -} - -impl Severity { - pub fn to_string(&self) -> &'static str { - match *self { - Severity::ERROR => "ERROR", - Severity::WARNING => "WARNING", - Severity::INFO => "INFO", - } - } -} - -pub struct SourceMessage { - pub severity: Severity, - pub sourcerange: Option, - pub message: String, -} - -/* ----------------- Model ----------------- */ - -pub enum StructureElementKind { - Var, - Function, - Struct, - Union, - Impl, - Trait, - Enum, - EnumVariant, - ExternCrate, - Mod, - Use, - MacroDef, - Existential, - TraitAlias, - TypeAlias, -} - -impl StructureElementKind { - pub fn to_string(&self) -> &'static str { - match *self { - StructureElementKind::Var => "Var", - StructureElementKind::Function => "Function", - StructureElementKind::Struct => "Struct", - StructureElementKind::Union => "Union", - StructureElementKind::Impl => "Impl", - StructureElementKind::Trait => "Trait", - StructureElementKind::Enum => "Enum", - StructureElementKind::EnumVariant => "EnumVariant", - StructureElementKind::ExternCrate => "ExternCrate", - StructureElementKind::Mod => "Mod", - StructureElementKind::Use => "Use", - StructureElementKind::MacroDef => "Macro", - StructureElementKind::TypeAlias => "TypeAlias", - StructureElementKind::Existential => "Existential", - StructureElementKind::TraitAlias => "TraitAlias", - } - } -} - -pub struct StructureElement { - pub name: String, - pub kind: StructureElementKind, - pub sourcerange: SourceRange, - - pub type_desc: String, - pub children: Vec, -} +// Copyright 2016 Bruno Medeiros +// +// 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. + +use crate::syntex_syntax::source_map::{CharPos, Loc, Span}; +use crate::syntex_errors::{SourceMapperDyn}; + +#[derive(Debug, Clone, Copy)] +pub struct LineColumnPosition { + /// The (1-based) line number + pub line: usize, + /// The (0-based) column offset + pub col: CharPos, +} + +#[derive(Debug, Clone, Copy)] +pub struct SourceRange { + pub start_pos: LineColumnPosition, + pub end_pos: LineColumnPosition, +} + +impl SourceRange { + pub fn new(codemap: &SourceMapperDyn, span: Span) -> SourceRange { + let startLoc = codemap.lookup_char_pos(span.lo()); + let endLoc = codemap.lookup_char_pos(span.hi()); + + SourceRange::from_loc(startLoc, endLoc) + } + + pub fn from_loc(startLoc: Loc, endLoc: Loc) -> SourceRange { + SourceRange { + start_pos: LineColumnPosition { line: startLoc.line, col: startLoc.col }, + end_pos: LineColumnPosition { line: endLoc.line, col: endLoc.col }, + } + } +} + +pub fn source_range(start_line: usize, start_col: usize, end_line: usize, end_col: usize) -> SourceRange { + SourceRange { + start_pos: LineColumnPosition { line: start_line, col: CharPos(start_col) }, + end_pos: LineColumnPosition { line: end_line, col: CharPos(end_col) }, + } +} + +/* ----------------- ----------------- */ + +//use ::util::core::*; + +pub enum Severity { + INFO, + WARNING, + ERROR, +} + +impl Severity { + pub fn to_string(&self) -> &'static str { + match *self { + Severity::ERROR => "ERROR", + Severity::WARNING => "WARNING", + Severity::INFO => "INFO", + } + } +} + +pub struct SourceMessage { + pub severity: Severity, + pub sourcerange: Option, + pub message: String, +} + +/* ----------------- Model ----------------- */ + +#[derive(Clone, Copy, Eq, PartialEq)] +pub enum StructureElementKind { + Var, + Function, + Struct, + Union, + Impl, + Trait, + Enum, + EnumVariant, + ExternCrate, + Mod, + Use, + MacroDef, + OpaqueTy, + TraitAlias, + TypeAlias, +} + +impl StructureElementKind { + pub fn to_string(&self) -> &'static str { + match *self { + StructureElementKind::Var => "Var", + StructureElementKind::Function => "Function", + StructureElementKind::Struct => "Struct", + StructureElementKind::Union => "Union", + StructureElementKind::Impl => "Impl", + StructureElementKind::Trait => "Trait", + StructureElementKind::Enum => "Enum", + StructureElementKind::EnumVariant => "EnumVariant", + StructureElementKind::ExternCrate => "ExternCrate", + StructureElementKind::Mod => "Mod", + StructureElementKind::Use => "Use", + StructureElementKind::MacroDef => "Macro", + StructureElementKind::TypeAlias => "TypeAlias", + StructureElementKind::OpaqueTy => "OpaqueTy", + StructureElementKind::TraitAlias => "TraitAlias", + } + } +} + +pub struct StructureElement { + pub name: String, + pub kind: StructureElementKind, + pub sourcerange: SourceRange, + + pub type_desc: String, + pub children: Vec, +} diff --git a/src/structure_visitor.rs b/src/structure_visitor.rs index 1face09..92ef1b8 100644 --- a/src/structure_visitor.rs +++ b/src/structure_visitor.rs @@ -1,614 +1,614 @@ -// Copyright 2015 Bruno Medeiros -// -// 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. - -//! -//! Write a parse structure into a TokenWriter -//! - -use std; - -use source_model::*; -use util::core::*; - -use syntex_syntax::ast::*; -use syntex_syntax::codemap::{CodeMap, Span}; -use syntex_syntax::visit::*; - -pub struct StructureVisitor<'ps> { - pub codemap: &'ps CodeMap, - pub parentIsStruct: bool, - pub parentIsUnion: bool, - pub elements: Vec, -} - -impl<'ps> StructureVisitor<'ps> { - pub fn new(codemap: &'ps CodeMap) -> StructureVisitor<'ps> { - StructureVisitor { - codemap: codemap, - parentIsStruct: false, - parentIsUnion: false, - elements: vec![], - } - } - - pub fn write_element_do(&mut self, ident: &str, kind: StructureElementKind, sourcerange: SourceRange, type_desc: String, walkFn: FN) -> Void - where - FN: Fn(&mut Self), - { - let mut siblings = vec![]; - std::mem::swap(&mut self.elements, &mut siblings); - - walkFn(self); // self.elements now has children - - std::mem::swap(&mut self.elements, &mut siblings); - let children = siblings; - - let element = StructureElement { - name: String::from(ident), - kind: kind, - sourcerange: sourcerange, - type_desc: type_desc, - children: children, - }; - - self.elements.push(element); - Ok(()) - } - - pub fn write_element_handled(&mut self, ident: &str, kind: StructureElementKind, sourceRange: SourceRange, type_desc: String, walkFn: FN) - where - FN: Fn(&mut Self), - { - use std::io::Write; - - match self.write_element_do(ident, kind, sourceRange, type_desc, walkFn) { - Ok(ok) => ok, - Err(error) => { - std::io::stderr().write_fmt(format_args!("Error writing element: {}", error)).ok(); - } - } - } - - pub fn write_element_TODO(&mut self, ident: Ident, kind: StructureElementKind, span: Span, walkFn: FN) - where - FN: Fn(&mut Self), - { - self.write_element(ident, kind, span, "".to_string(), walkFn); - } - - pub fn write_element(&mut self, ident: Ident, kind: StructureElementKind, span: Span, type_desc: String, walkFn: FN) - where - FN: Fn(&mut Self), - { - self.write_element_handled(&*ident.name.as_str(), kind, SourceRange::new(self.codemap, span), type_desc, walkFn) - } - - /* ----------------- ----------------- */ - - fn write_ItemUse(&mut self, tree: &UseTree) { - use std::ops::Index; - use syntex_syntax::ast; - use syntex_syntax::print::pprust; - - let kind = StructureElementKind::Use; - let mut useSpec = String::new(); - - fn writePath(outString: &mut String, path: &ast::Path) { - outString.push_str(&pprust::path_to_string(path)); - } - - match tree.kind { - UseTreeKind::Simple(ref ident, _ , _) => { - writePath(&mut useSpec, &tree.prefix); - - let path: &ast::Path = &tree.prefix; - if path.segments.len() == 0 { - return; - } - let lastSegment = path.segments.index(path.segments.len() - 1); - if let Some(ident) = ident { - if &lastSegment.ident != ident { - useSpec.push_str(&" as "); - useSpec.push_str(&*ident.name.as_str()); - } - } - } - UseTreeKind::Glob => { - useSpec.push_str(&pprust::path_to_string(&tree.prefix)); - useSpec.push_str(&"::*"); - } - UseTreeKind::Nested(ref trees) => { - writePath(&mut useSpec, &tree.prefix); - - useSpec.push_str("::{ "); - for treenode in trees { - self.write_ItemUse(&treenode.0); - } - useSpec.push_str("}"); - } - } - - self.write_element_handled(&useSpec, kind, SourceRange::new(self.codemap, tree.span), "".to_string(), &|_: &mut Self| {}) - } - - fn get_type_desc_from_fndecl(&mut self, fd: &FnDecl) -> String { - let mut type_desc = "".to_string(); - - type_desc.push('('); - let mut needs_sep = false; - - for arg in &fd.inputs { - let arg: &Arg = arg; - // let pat : &Pat_ = &arg.pat.node; - let pat_span = arg.pat.span; - - if needs_sep { - type_desc.push_str(", "); - } - needs_sep = true; - - if let Ok(snippet) = self.codemap.span_to_snippet(arg.ty.span) { - if !snippet.is_empty() { - type_desc.push_str(&snippet); - continue; - } - } - - if let Ok(snippet) = self.codemap.span_to_snippet(pat_span) { - if snippet.ends_with("self") { - type_desc.push_str(&snippet); - continue; - } - } - } - type_desc.push_str(")"); - - if let FunctionRetTy::Ty(ref _ret) = fd.output { - if let Ok(ret_snippet) = self.codemap.span_to_snippet(fd.output.span()) { - type_desc.push_str(" -> "); - type_desc.push_str(&ret_snippet); - } - } - - type_desc - } - - fn write_function_element(&mut self, ident: Ident, span: Span, fd: &FnDecl, walkFn: &Fn(&mut Self)) { - let type_desc = self.get_type_desc_from_fndecl(&fd); - - self.write_element(ident, StructureElementKind::Function, span, type_desc, walkFn); - } -} - -impl<'v> Visitor<'v> for StructureVisitor<'v> { - fn visit_name(&mut self, _span: Span, _name: Name) { - // Nothing to do. - } - fn visit_ident(&mut self, ident: Ident) { - walk_ident(self, ident); - } - - fn visit_mod(&mut self, m: &'v Mod, _span: Span, _attrs: &[Attribute], _nodeid: NodeId) { - // let sr = &SourceRange::new(self.codemap, span); - // self.write_element_handled("_file_", StructureElementKind::File, sr, |_self : &mut Self| { - // walk_mod(_self, m); - // }) - walk_mod(self, m); - } - - fn visit_item(&mut self, item: &'v Item) { - let kind; - let mut type_desc = "".to_string(); - - let noop_walkFn = &|_self: &mut Self| {}; - - let walkFn: &Fn(&mut Self) = &|_self: &mut Self| { - walk_item(_self, item); - }; - - match item.node { - ItemKind::Existential(ref _bounds, ref _generics) => { - kind = StructureElementKind::Existential; - } - ItemKind::TraitAlias(ref _generics, ref _bounds) => { - kind = StructureElementKind::TraitAlias; - } - ItemKind::ExternCrate(_opt_name) => { - kind = StructureElementKind::ExternCrate; - } - ItemKind::Use(ref vp) => { - self.write_ItemUse(vp); - return; - } - ItemKind::Static(ref typ, _, ref _expr) | ItemKind::Const(ref typ, ref _expr) => { - if let Ok(snippet) = self.codemap.span_to_snippet(typ.span) { - type_desc.push_str(&snippet); - } - self.write_element(item.ident, StructureElementKind::Var, item.span, type_desc, noop_walkFn); - return; - } - ItemKind::Fn(ref declaration, header, ref _generics, ref body) => { - self.visit_fn(FnKind::ItemFn(item.ident, header, &item.vis, body), declaration, item.span, item.id); - return; - } - ItemKind::Mod(ref _module) => { - kind = StructureElementKind::Mod; - } - ItemKind::ForeignMod(ref _foreign_module) => { - kind = StructureElementKind::Mod; - } - ItemKind::Ty(ref _typ, ref _type_parameters) => { - kind = StructureElementKind::TypeAlias; - } - ItemKind::Enum(ref _enum_definition, ref _type_parameters) => { - kind = StructureElementKind::Enum; - } - ItemKind::Impl(_, _, ref _type_parameters, _, ref _opt_trait_reference, ref _typ, ref _impl_items) => { - kind = StructureElementKind::Impl; - } - ItemKind::Struct(ref _struct_definition, ref _generics) => { - // Go straight in - self.parentIsStruct = true; - walk_item(self, item); - return; - } - ItemKind::Union(ref _struct_definition, ref _generics) => { - self.parentIsUnion = true; - walk_item(self, item); - return; - } - ItemKind::Trait(_, _, ref _generics, ref _bounds, ref _methods) => { - kind = StructureElementKind::Trait; - } - ItemKind::Mac(ref mac) => { - self.visit_mac(mac); - return; - } - ItemKind::GlobalAsm(ref asm) => { - self.visit_global_asm(asm); - return; - } - ItemKind::MacroDef(ref macro_def) => { - self.visit_mac_def(macro_def, item.id); - return; - } - } - - self.write_element(item.ident, kind, item.span, type_desc, walkFn); - } - - fn visit_enum_def(&mut self, enum_def: &'v EnumDef, generics: &'v Generics, nodeid: NodeId, _span: Span) { - // This element is covered by an item definition - walk_enum_def(self, enum_def, generics, nodeid) - } - - fn visit_variant(&mut self, v: &'v Variant, g: &'v Generics, nodeid: NodeId) { - // This element is covered by an enum_def call - walk_variant(self, v, g, nodeid); - } - - fn visit_variant_data(&mut self, s: &'v VariantData, ident: Ident, _: &'v Generics, _: NodeId, span: Span) { - let mut kind = StructureElementKind::EnumVariant; - if self.parentIsStruct { - kind = StructureElementKind::Struct; - self.parentIsStruct = false; - } - if self.parentIsUnion { - kind = StructureElementKind::Union; - self.parentIsUnion = false; - } - - self.write_element_TODO(ident, kind, span, |_self: &mut Self| { - walk_struct_def(_self, s); - }); - } - - fn visit_struct_field(&mut self, sf: &'v StructField) { - if let Some(ident) = sf.ident { - self.write_element_TODO(ident, StructureElementKind::Var, sf.span, |_self: &mut Self| { - walk_struct_field(_self, sf); - }); - } - } - - fn visit_trait_item(&mut self, ti: &'v TraitItem) { - let kind; - - match ti.node { - TraitItemKind::Const(ref _ty, ref _default) => { - kind = StructureElementKind::Var; - } - TraitItemKind::Method(ref sig, _) => { - self.write_function_element(ti.ident, ti.span, &sig.decl, &|_self: &mut Self| { - walk_trait_item(_self, ti); - }); - return; - } - TraitItemKind::Type(ref _bounds, ref _default) => { - kind = StructureElementKind::TypeAlias; - } - TraitItemKind::Macro(ref mac) => { - self.visit_mac(mac); - return; - } - } - - self.write_element_TODO(ti.ident, kind, ti.span, |_self: &mut Self| { - walk_trait_item(_self, ti); - }); - } - - fn visit_impl_item(&mut self, ii: &'v ImplItem) { - let kind; - - match ii.node { - ImplItemKind::Const(ref _ty, ref _default) => { - kind = StructureElementKind::Var; - } - ImplItemKind::Type(ref _type) => { - kind = StructureElementKind::TypeAlias; - } - ImplItemKind::Method(_, _) | ImplItemKind::Macro(_) => { - walk_impl_item(self, ii); - return; - } - ImplItemKind::Existential(_) => { - kind = StructureElementKind::Existential; - } - } - - self.write_element_TODO(ii.ident, kind, ii.span, |_self: &mut Self| { - walk_impl_item(_self, ii); - }); - } - - /* ----------------- Function ----------------- */ - - fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, span: Span, _nodeid: NodeId) { - let ident: Ident; - - match fk { - FnKind::Method(_ident, ref _MethodSig, _option, _b) => { - ident = _ident; - } - FnKind::ItemFn(_ident, FnHeader { asyncness: _Asyncness, unsafety: _Unsafety, constness: _Constness, abi: _Abi }, _Visibility, _b) => { - ident = _ident; - } - FnKind::Closure(_) => { - return; - } - }; - - self.write_function_element(ident, span, fd, &|_self: &mut Self| { - walk_fn(_self, fk, fd, span); - }); - } - - fn visit_foreign_item(&mut self, foreign_item: &'v ForeignItem) { - let kind; - - match foreign_item.node { - ForeignItemKind::Fn(ref _function_declaration, ref _generics) => { - kind = StructureElementKind::Function; - } - ForeignItemKind::Static(ref _typ, _) => { - kind = StructureElementKind::Var; - } - ForeignItemKind::Ty => { - kind = StructureElementKind::TypeAlias; - } - ForeignItemKind::Macro(_) => { - kind = StructureElementKind::MacroDef; - } - } - - self.write_element_TODO(foreign_item.ident, kind, foreign_item.span, |_self: &mut Self| { - walk_foreign_item(_self, foreign_item); - }); - } - - fn visit_trait_ref(&mut self, t: &'v TraitRef) { - walk_trait_ref(self, t) - } - fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: &'v TraitBoundModifier) { - walk_poly_trait_ref(self, t, m) - } - - fn visit_lifetime(&mut self, lifetime: &'v Lifetime) { - walk_lifetime(self, lifetime) - } - - fn visit_local(&mut self, l: &'v Local) { - walk_local(self, l) - } - fn visit_block(&mut self, b: &'v Block) { - walk_block(self, b) - } - fn visit_stmt(&mut self, s: &'v Stmt) { - walk_stmt(self, s) - } - fn visit_arm(&mut self, a: &'v Arm) { - walk_arm(self, a) - } - fn visit_pat(&mut self, p: &'v Pat) { - walk_pat(self, p) - } - fn visit_expr(&mut self, _ex: &Expr) { - // Comment, no need to visit node insinde expressions - //walk_expr(self, ex) - } - fn visit_expr_post(&mut self, _ex: &Expr) {} - fn visit_ty(&mut self, t: &'v Ty) { - walk_ty(self, t) - } - fn visit_generics(&mut self, g: &'v Generics) { - walk_generics(self, g) - } - fn visit_mac(&mut self, mac: &Mac) { - walk_mac(self, mac) - } - fn visit_path(&mut self, path: &'v Path, _id: NodeId) { - walk_path(self, path) - } - fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) { - walk_path_segment(self, path_span, path_segment) - } - fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding) { - walk_assoc_type_binding(self, type_binding) - } - fn visit_attribute(&mut self, _attr: &Attribute) {} - fn visit_vis(&mut self, vis: &'v Visibility) { - walk_vis(self, vis) - } -} - -#[test] -fn tests_describe_structure() { - use parse_describe; - use std::cell::RefCell; - use std::rc::Rc; - use token_writer::TokenWriter; - use util::tests::*; - - fn test_describe_structure(source: &str, expected: &str) { - let stringRc = Rc::new(RefCell::new(String::new())); - - { - let (messages, elements) = parse_describe::parse_crate_with_messages(source); - - let mut tokenWriter = TokenWriter { out: stringRc.clone() }; - parse_describe::write_parse_analysis_contents(messages, elements, &mut tokenWriter).ok().unwrap(); - } - - let expected: &str = &(String::from("MESSAGES {\n}") + (if expected.is_empty() { "" } else { "\n" }) + expected); - - let result = unwrap_Rc_RefCell(stringRc); - let result = result.trim(); - check_equal(result, expected); - } - - test_describe_structure("extern crate xx;", r#"ExternCrate { "xx" { 0:0 0:16 } {} "" {} }"#); - - test_describe_structure("const xx : u32 = 1;", r#"Var { "xx" { 0:0 0:19 } {} "u32" {} }"#); - - test_describe_structure("mod myMod ; ", r#"Mod { "myMod" { 0:0 0:13 } {} "" {} }"#); - test_describe_structure("mod myMod { }", r#"Mod { "myMod" { 0:0 0:13 } {} "" {} }"#); - test_describe_structure( - "mod myMod { static xx : u32 = 2; }", - r#"Mod { "myMod" { 0:0 0:34 } {} "" {} - Var { "xx" { 0:12 0:32 } {} "u32" {} } -}"#, - ); - - test_describe_structure("fn xx() { }", r#"Function { "xx" { 0:0 0:11 } {} "()" {} }"#); - test_describe_structure("fn xx(a : &str) -> u32 { }", r#"Function { "xx" { 0:0 0:26 } {} "(&str) -> u32" {} }"#); - test_describe_structure("fn xx(blah : Vec, x : &'v str) -> u32 { }", r#"Function { "xx" { 0:0 0:46 } {} "(Vec, &'v str) -> u32" {} }"#); - // Test "deceiving" case - test_describe_structure("fn xx(my_self : &str) -> u32 { }", r#"Function { "xx" { 0:0 0:32 } {} "(&str) -> u32" {} }"#); - - test_describe_structure("type MyType = &u32;", r#"TypeAlias { "MyType" { 0:0 0:24 } {} "" {} }"#); - - test_describe_structure( - "enum MyEnum { Alpha, Beta, } ", - r#"Enum { "MyEnum" { 0:0 0:28 } {} "" {} - EnumVariant { "Alpha" { 0:14 0:19 } {} "" {} } - EnumVariant { "Beta" { 0:21 0:25 } {} "" {} } -}"#, - ); - test_describe_structure( - "enum MyEnum { Alpha(T), Beta(U), } ", - r#"Enum { "MyEnum" { 0:0 0:40 } {} "" {} - EnumVariant { "Alpha" { 0:20 0:28 } {} "" {} } - EnumVariant { "Beta" { 0:30 0:37 } {} "" {} } -}"#, - ); - - test_describe_structure("struct MyStruct ( u32, blah ); ", r#"Struct { "MyStruct" { 0:0 0:35 } {} "" {} }"#); - test_describe_structure( - "struct MyStruct { foo : u32, } ", - r#"Struct { "MyStruct" { 0:0 0:30 } {} "" {} - Var { "foo" { 0:18 0:27 } {} "" {} } -}"#, - ); - test_describe_structure( - "union MyUnion { foo : u32, } ", - r#"Union { "MyUnion" { 0:0 0:28 } {} "" {} - Var { "foo" { 0:16 0:25 } {} "" {} } -}"#, - ); - - test_describe_structure("trait MyTrait { } ", r#"Trait { "MyTrait" { 0:0 0:17 } {} "" {} }"#); - test_describe_structure( - "trait MyTrait : Foo { fn xxx(); } ", - r#"Trait { "MyTrait" { 0:0 0:33 } {} "" {} - Function { "xxx" { 0:22 0:31 } {} "()" {} } -}"#, - ); - test_describe_structure( - "trait MyTrait : Foo { type N: fmt::Display; fn xxx(&self); const foo :u32 = 3; } ", - r#"Trait { "MyTrait" { 0:0 0:80 } {} "" {} - TypeAlias { "N" { 0:22 0:43 } {} "" {} } - Function { "xxx" { 0:44 0:58 } {} "(&self)" {} } - Var { "foo" { 0:59 0:78 } {} "" {} } -}"#, - ); - - /* FIXME: review - test_describe_structure("impl MyType { } ", r#"Impl { "MyType" { 0:0 0:15 } {} "" {} }"#); - test_describe_structure("impl MyTrait for MyType { } ", r#"Impl { "MyType.MyTrait" { 0:0 0:27 } {} "" {} }"#); - test_describe_structure("impl MyTrait { type N= fmt::Display; fn xx(){} const foo :u32 = 3; } ", -r#"Impl { "MyTrait" { 0:0 0:75 } {} "" {} - TypeAlias { "N" { 0:22 0:43 } {} "" {} } - Function { "xx" { 0:44 0:53 } {} "()" {} } - Var { "foo" { 0:54 0:73 } {} "" {} } -}"#); - */ - - test_describe_structure("use blah;", r#"Use { "blah" { 0:0 0:9 } {} "" {} }"#); - test_describe_structure("use blah as foo;", r#"Use { "blah as foo" { 0:0 0:16 } {} "" {} }"#); - // TODO: this is not printing the global path prefix, seems to be a limitation from libsyntax? - test_describe_structure("use ::blah::foo as myfoo;", r#"Use { "::blah::foo as myfoo" { 0:0 0:25 } {} "" {} }"#); - test_describe_structure("use ::blah::foo::*;", r#"Use { "::blah::foo::*" { 0:0 0:19 } {} "" {} }"#); - test_describe_structure("use blah::foo:: { One as OtherOne, self as Two };", r#"Use { "blah::foo::{ One as OtherOne, self as Two, }" { 0:0 0:49 } {} "" {} }"#); - - test_describe_structure("my_macro!(asf); ", ""); - - // test: visit_mac! visit method - test_describe_structure("fn foo() { my_macro!(asf); }", r#"Function { "foo" { 0:0 0:28 } {} "()" {} }"#); - - test_describe_structure("macro_rules! foo { (x => $e:expr) => (); }", r#""#); - // TODO: macro definitions, unfortunately can't get that info easily from syntax_syntex - // test_describe_structure("macro_rules! five_times { ($x:expr) => (5 * $x); }", - // r#"Macro { "foo" { 0:0 0:28 } {} "" {} }"#); - - // Test pub extern - test_describe_structure("pub extern crate my_crate;", r#"ExternCrate { "my_crate" { 0:0 0:26 } {} "" {} }"#); - - test_describe_structure( - "extern { fn ext(p : u32); }", - r#"Mod { "" { 0:0 0:27 } {} "" {} - Function { "ext" { 0:9 0:25 } {} "" {} } -}"#, - ); - test_describe_structure( - "extern { fn ext(p : u32); \n static extVar: u8; }", - r#"Mod { "" { 0:0 1:21 } {} "" {} - Function { "ext" { 0:9 0:25 } {} "" {} } - Var { "extVar" { 1:1 1:19 } {} "" {} } -}"#, - ); - - // Test with a lexer error, - // test_describe_structure("const xx : u32 = '", r#"Var { "xx" { 1 0 1 19 } {} {} {} }"#); -} +// Copyright 2015 Bruno Medeiros +// +// 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. + +//! +//! Write a parse structure into a TokenWriter +//! + +use crate::source_model::*; +use crate::util::core::*; + +use crate::syntex_syntax::ast::*; +use crate::syntex_syntax::source_map::{SourceMap, Span}; +use crate::syntex_syntax::visit::*; + +pub struct StructureVisitor<'ps> { + pub codemap: &'ps SourceMap, + pub parentIsStruct: bool, + pub parentIsUnion: bool, + pub elements: Vec, +} + +impl<'ps> StructureVisitor<'ps> { + pub fn new(codemap: &'ps SourceMap) -> StructureVisitor<'ps> { + StructureVisitor { + codemap: codemap, + parentIsStruct: false, + parentIsUnion: false, + elements: vec![], + } + } + + pub fn write_element_do(&mut self, ident: &str, kind: StructureElementKind, sourcerange: SourceRange, type_desc: String, walkFn: FN) -> Void + where + FN: Fn(&mut Self), + { + let mut siblings = vec![]; + std::mem::swap(&mut self.elements, &mut siblings); + + walkFn(self); // self.elements now has children + + std::mem::swap(&mut self.elements, &mut siblings); + let children = siblings; + + let element = StructureElement { + name: String::from(ident), + kind: kind, + sourcerange: sourcerange, + type_desc: type_desc, + children: children, + }; + + self.elements.push(element); + Ok(()) + } + + pub fn write_element_handled(&mut self, ident: &str, kind: StructureElementKind, sourceRange: SourceRange, type_desc: String, walkFn: FN) + where + FN: Fn(&mut Self), + { + use std::io::Write; + + match self.write_element_do(ident, kind, sourceRange, type_desc, walkFn) { + Ok(ok) => ok, + Err(error) => { + std::io::stderr().write_fmt(format_args!("Error writing element: {}", error)).ok(); + } + } + } + + pub fn write_element_TODO(&mut self, ident: Ident, kind: StructureElementKind, span: Span, walkFn: FN) + where + FN: Fn(&mut Self), + { + self.write_element(ident, kind, span, "".to_string(), walkFn); + } + + pub fn write_element(&mut self, ident: Ident, kind: StructureElementKind, span: Span, type_desc: String, walkFn: FN) + where + FN: Fn(&mut Self), + { + self.write_element_handled(&*ident.name.as_str(), kind, SourceRange::new(self.codemap, span), type_desc, walkFn) + } + + /* ----------------- ----------------- */ + + fn write_ItemUse(&mut self, tree: &UseTree) { + use std::ops::Index; + use crate::syntex_syntax::ast; + use crate::syntex_syntax::print::pprust; + + let kind = StructureElementKind::Use; + let mut useSpec = String::new(); + + fn writePath(outString: &mut String, path: &ast::Path) { + outString.push_str(&pprust::path_to_string(path)); + } + + match tree.kind { + UseTreeKind::Simple(ref ident, _ , _) => { + writePath(&mut useSpec, &tree.prefix); + + let path: &ast::Path = &tree.prefix; + if path.segments.len() == 0 { + return; + } + let lastSegment = path.segments.index(path.segments.len() - 1); + if let Some(ident) = ident { + if &lastSegment.ident != ident { + useSpec.push_str(&" as "); + useSpec.push_str(&*ident.name.as_str()); + } + } + } + UseTreeKind::Glob => { + useSpec.push_str(&pprust::path_to_string(&tree.prefix)); + useSpec.push_str(&"::*"); + } + UseTreeKind::Nested(ref trees) => { + writePath(&mut useSpec, &tree.prefix); + + useSpec.push_str("::{ "); + for treenode in trees { + self.write_ItemUse(&treenode.0); + } + useSpec.push_str("}"); + } + } + + self.write_element_handled(&useSpec, kind, SourceRange::new(self.codemap, tree.span), "".to_string(), &|_: &mut Self| {}) + } + + fn get_type_desc_from_fndecl(&mut self, fd: &FnDecl) -> String { + let mut type_desc = "".to_string(); + + type_desc.push('('); + let mut needs_sep = false; + + for arg in &fd.inputs { + let pat_span = arg.pat.span; + + if needs_sep { + type_desc.push_str(", "); + } + needs_sep = true; + + if let Ok(snippet) = self.codemap.span_to_snippet(arg.ty.span) { + if !snippet.is_empty() { + type_desc.push_str(&snippet); + continue; + } + } + + if let Ok(snippet) = self.codemap.span_to_snippet(pat_span) { + if snippet.ends_with("self") { + type_desc.push_str(&snippet); + continue; + } + } + } + type_desc.push_str(")"); + + if let FunctionRetTy::Ty(ref _ret) = fd.output { + if let Ok(ret_snippet) = self.codemap.span_to_snippet(fd.output.span()) { + type_desc.push_str(" -> "); + type_desc.push_str(&ret_snippet); + } + } + + type_desc + } + + fn write_function_element(&mut self, ident: Ident, span: Span, fd: &FnDecl, walkFn: &dyn Fn(&mut Self)) { + let type_desc = self.get_type_desc_from_fndecl(&fd); + + self.write_element(ident, StructureElementKind::Function, span, type_desc, walkFn); + } +} + +impl<'v> Visitor<'v> for StructureVisitor<'v> { + fn visit_name(&mut self, _span: Span, _name: Name) { + // Nothing to do. + } + fn visit_ident(&mut self, ident: Ident) { + walk_ident(self, ident); + } + + fn visit_mod(&mut self, m: &'v Mod, _span: Span, _attrs: &[Attribute], _nodeid: NodeId) { + // let sr = &SourceRange::new(self.codemap, span); + // self.write_element_handled("_file_", StructureElementKind::File, sr, |_self : &mut Self| { + // walk_mod(_self, m); + // }) + walk_mod(self, m); + } + + fn visit_item(&mut self, item: &'v Item) { + let kind; + let mut type_desc = "".to_string(); + + let noop_walkFn = &|_self: &mut Self| {}; + + let walkFn: &dyn Fn(&mut Self) = &|_self: &mut Self| { + walk_item(_self, item); + }; + + match item.kind { + ItemKind::OpaqueTy(ref _bounds, ref _generics) => { + kind = StructureElementKind::OpaqueTy; + } + ItemKind::TraitAlias(ref _generics, ref _bounds) => { + kind = StructureElementKind::TraitAlias; + } + ItemKind::ExternCrate(_opt_name) => { + kind = StructureElementKind::ExternCrate; + } + ItemKind::Use(ref vp) => { + self.write_ItemUse(vp); + return; + } + ItemKind::Static(ref typ, _, ref _expr) | ItemKind::Const(ref typ, ref _expr) => { + if let Ok(snippet) = self.codemap.span_to_snippet(typ.span) { + type_desc.push_str(&snippet); + } + self.write_element(item.ident, StructureElementKind::Var, item.span, type_desc, noop_walkFn); + return; + } + ItemKind::Fn(ref declaration, ref header, ref _generics, ref body) => { + self.visit_fn(FnKind::ItemFn(item.ident, header, &item.vis, body), declaration, item.span, item.id); + return; + } + ItemKind::Mod(ref _module) => { + kind = StructureElementKind::Mod; + } + ItemKind::ForeignMod(ref _foreign_module) => { + kind = StructureElementKind::Mod; + } + ItemKind::TyAlias(ref _typ, ref _type_parameters) => { + kind = StructureElementKind::TypeAlias; + } + ItemKind::Enum(ref _enum_definition, ref _type_parameters) => { + kind = StructureElementKind::Enum; + } + ItemKind::Impl(_, _, ref _type_parameters, _, ref _opt_trait_reference, ref _typ, ref _impl_items) => { + kind = StructureElementKind::Impl; + } + ItemKind::Struct(ref _struct_definition, ref _generics) => { + // Go straight in + self.parentIsStruct = true; + walk_item(self, item); + return; + } + ItemKind::Union(ref _struct_definition, ref _generics) => { + self.parentIsUnion = true; + walk_item(self, item); + return; + } + ItemKind::Trait(_, _, ref _generics, ref _bounds, ref _methods) => { + kind = StructureElementKind::Trait; + } + ItemKind::Mac(ref mac) => { + self.visit_mac(mac); + return; + } + ItemKind::GlobalAsm(ref asm) => { + self.visit_global_asm(asm); + return; + } + ItemKind::MacroDef(ref macro_def) => { + self.visit_mac_def(macro_def, item.id); + return; + } + } + + self.write_element(item.ident, kind, item.span, type_desc, walkFn); + } + + fn visit_enum_def(&mut self, enum_def: &'v EnumDef, generics: &'v Generics, nodeid: NodeId, _span: Span) { + // This element is covered by an item definition + walk_enum_def(self, enum_def, generics, nodeid) + } + + fn visit_variant(&mut self, v: &'v Variant) { + // This element is covered by an enum_def call + walk_variant(self, v); + } + + fn visit_variant_data(&mut self, s: &'v VariantData) { + let mut kind = StructureElementKind::EnumVariant; + if self.parentIsStruct { + kind = StructureElementKind::Struct; + self.parentIsStruct = false; + } + if self.parentIsUnion { + kind = StructureElementKind::Union; + self.parentIsUnion = false; + } + match s { + VariantData::Struct(fields, _) | VariantData::Tuple(fields, _) => { + for field in fields { + self.write_element_TODO(field.ident.unwrap_or(Ident::invalid()), kind, field.span, |_self: &mut Self| { + walk_struct_def(_self, s); + }); + } + }, + VariantData::Unit(_) => return, + }; + } + + fn visit_struct_field(&mut self, sf: &'v StructField) { + if let Some(ident) = sf.ident { + self.write_element_TODO(ident, StructureElementKind::Var, sf.span, |_self: &mut Self| { + walk_struct_field(_self, sf); + }); + } + } + + fn visit_trait_item(&mut self, ti: &'v TraitItem) { + let kind; + + match ti.kind { + TraitItemKind::Const(ref _ty, ref _default) => { + kind = StructureElementKind::Var; + } + TraitItemKind::Method(ref sig, _) => { + self.write_function_element(ti.ident, ti.span, &sig.decl, &|_self: &mut Self| { + walk_trait_item(_self, ti); + }); + return; + } + TraitItemKind::Type(ref _bounds, ref _default) => { + kind = StructureElementKind::TypeAlias; + } + TraitItemKind::Macro(ref mac) => { + self.visit_mac(mac); + return; + } + } + + self.write_element_TODO(ti.ident, kind, ti.span, |_self: &mut Self| { + walk_trait_item(_self, ti); + }); + } + + fn visit_impl_item(&mut self, ii: &'v ImplItem) { + let kind; + + match ii.kind { + ImplItemKind::Const(ref _ty, ref _default) => { + kind = StructureElementKind::Var; + } + ImplItemKind::TyAlias(ref _type) => { + kind = StructureElementKind::TypeAlias; + } + ImplItemKind::Method(_, _) | ImplItemKind::Macro(_) => { + walk_impl_item(self, ii); + return; + } + ImplItemKind::OpaqueTy(_) => { + kind = StructureElementKind::OpaqueTy; + } + } + + self.write_element_TODO(ii.ident, kind, ii.span, |_self: &mut Self| { + walk_impl_item(_self, ii); + }); + } + + /* ----------------- Function ----------------- */ + + fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, span: Span, _nodeid: NodeId) { + let ident: Ident; + + match fk { + FnKind::Method(_ident, ref _MethodSig, _option, _b) => { + ident = _ident; + } + FnKind::ItemFn(_ident, FnHeader { asyncness: _Asyncness, unsafety: _Unsafety, constness: _Constness, abi: _Abi }, _Visibility, _b) => { + ident = _ident; + } + FnKind::Closure(_) => { + return; + } + }; + + self.write_function_element(ident, span, fd, &|_self: &mut Self| { + walk_fn(_self, fk, fd, span); + }); + } + + fn visit_foreign_item(&mut self, foreign_item: &'v ForeignItem) { + let kind; + + match foreign_item.kind { + ForeignItemKind::Fn(ref _function_declaration, ref _generics) => { + kind = StructureElementKind::Function; + } + ForeignItemKind::Static(ref _typ, _) => { + kind = StructureElementKind::Var; + } + ForeignItemKind::Ty => { + kind = StructureElementKind::TypeAlias; + } + ForeignItemKind::Macro(_) => { + kind = StructureElementKind::MacroDef; + } + } + + self.write_element_TODO(foreign_item.ident, kind, foreign_item.span, |_self: &mut Self| { + walk_foreign_item(_self, foreign_item); + }); + } + + fn visit_trait_ref(&mut self, t: &'v TraitRef) { + walk_trait_ref(self, t) + } + fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: &'v TraitBoundModifier) { + walk_poly_trait_ref(self, t, m) + } + + fn visit_lifetime(&mut self, lifetime: &'v Lifetime) { + walk_lifetime(self, lifetime) + } + + fn visit_local(&mut self, l: &'v Local) { + walk_local(self, l) + } + fn visit_block(&mut self, b: &'v Block) { + walk_block(self, b) + } + fn visit_stmt(&mut self, s: &'v Stmt) { + walk_stmt(self, s) + } + fn visit_arm(&mut self, a: &'v Arm) { + walk_arm(self, a) + } + fn visit_pat(&mut self, p: &'v Pat) { + walk_pat(self, p) + } + fn visit_expr(&mut self, _ex: &Expr) { + // Comment, no need to visit node insinde expressions + //walk_expr(self, ex) + } + fn visit_expr_post(&mut self, _ex: &Expr) {} + fn visit_ty(&mut self, t: &'v Ty) { + walk_ty(self, t) + } + fn visit_generics(&mut self, g: &'v Generics) { + walk_generics(self, g) + } + fn visit_mac(&mut self, mac: &'v Mac) { + walk_mac(self, mac) + } + fn visit_path(&mut self, path: &'v Path, _id: NodeId) { + walk_path(self, path) + } + fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) { + walk_path_segment(self, path_span, path_segment) + } + fn visit_attribute(&mut self, _attr: &Attribute) {} + fn visit_vis(&mut self, vis: &'v Visibility) { + walk_vis(self, vis) + } +} + +#[test] +fn tests_describe_structure() { + use std::cell::RefCell; + use std::rc::Rc; + + use crate::parse_describe; + use crate::token_writer::TokenWriter; + use crate::util::tests::*; + + fn test_describe_structure(source: &str, expected: &str) { + let stringRc = Rc::new(RefCell::new(String::new())); + + { + let (messages, elements) = parse_describe::parse_crate_with_messages(source); + + let mut tokenWriter = TokenWriter { out: stringRc.clone() }; + parse_describe::write_parse_analysis_contents(messages, elements, &mut tokenWriter).ok().unwrap(); + } + + let expected: &str = &(String::from("MESSAGES {\n}") + (if expected.is_empty() { "" } else { "\n" }) + expected); + + let result = unwrap_Rc_RefCell(stringRc); + let result = result.trim(); + check_equal(result, expected); + } + + test_describe_structure("extern crate xx;", r#"ExternCrate { "xx" { 0:0 0:16 } {} "" {} }"#); + + test_describe_structure("const xx : u32 = 1;", r#"Var { "xx" { 0:0 0:19 } {} "u32" {} }"#); + + test_describe_structure("mod myMod ; ", r#"Mod { "myMod" { 0:0 0:13 } {} "" {} }"#); + test_describe_structure("mod myMod { }", r#"Mod { "myMod" { 0:0 0:13 } {} "" {} }"#); + test_describe_structure( + "mod myMod { static xx : u32 = 2; }", + r#"Mod { "myMod" { 0:0 0:34 } {} "" {} + Var { "xx" { 0:12 0:32 } {} "u32" {} } +}"#, + ); + + test_describe_structure("fn xx() { }", r#"Function { "xx" { 0:0 0:11 } {} "()" {} }"#); + test_describe_structure("fn xx(a : &str) -> u32 { }", r#"Function { "xx" { 0:0 0:26 } {} "(&str) -> u32" {} }"#); + test_describe_structure("fn xx(blah : Vec, x : &'v str) -> u32 { }", r#"Function { "xx" { 0:0 0:46 } {} "(Vec, &'v str) -> u32" {} }"#); + // Test "deceiving" case + test_describe_structure("fn xx(my_self : &str) -> u32 { }", r#"Function { "xx" { 0:0 0:32 } {} "(&str) -> u32" {} }"#); + + test_describe_structure("type MyType = &u32;", r#"TypeAlias { "MyType" { 0:0 0:24 } {} "" {} }"#); + + test_describe_structure( + "enum MyEnum { Alpha, Beta, } ", + r#"Enum { "MyEnum" { 0:0 0:28 } {} "" {} + EnumVariant { "Alpha" { 0:14 0:19 } {} "" {} } + EnumVariant { "Beta" { 0:21 0:25 } {} "" {} } +}"#, + ); + test_describe_structure( + "enum MyEnum { Alpha(T), Beta(U), } ", + r#"Enum { "MyEnum" { 0:0 0:40 } {} "" {} + EnumVariant { "Alpha" { 0:20 0:28 } {} "" {} } + EnumVariant { "Beta" { 0:30 0:37 } {} "" {} } +}"#, + ); + + test_describe_structure("struct MyStruct ( u32, blah ); ", r#"Struct { "MyStruct" { 0:0 0:35 } {} "" {} }"#); + test_describe_structure( + "struct MyStruct { foo : u32, } ", + r#"Struct { "MyStruct" { 0:0 0:30 } {} "" {} + Var { "foo" { 0:18 0:27 } {} "" {} } +}"#, + ); + test_describe_structure( + "union MyUnion { foo : u32, } ", + r#"Union { "MyUnion" { 0:0 0:28 } {} "" {} + Var { "foo" { 0:16 0:25 } {} "" {} } +}"#, + ); + + test_describe_structure("trait MyTrait { } ", r#"Trait { "MyTrait" { 0:0 0:17 } {} "" {} }"#); + test_describe_structure( + "trait MyTrait : Foo { fn xxx(); } ", + r#"Trait { "MyTrait" { 0:0 0:33 } {} "" {} + Function { "xxx" { 0:22 0:31 } {} "()" {} } +}"#, + ); + test_describe_structure( + "trait MyTrait : Foo { type N: fmt::Display; fn xxx(&self); const foo :u32 = 3; } ", + r#"Trait { "MyTrait" { 0:0 0:80 } {} "" {} + TypeAlias { "N" { 0:22 0:43 } {} "" {} } + Function { "xxx" { 0:44 0:58 } {} "(&self)" {} } + Var { "foo" { 0:59 0:78 } {} "" {} } +}"#, + ); + + /* FIXME: review + test_describe_structure("impl MyType { } ", r#"Impl { "MyType" { 0:0 0:15 } {} "" {} }"#); + test_describe_structure("impl MyTrait for MyType { } ", r#"Impl { "MyType.MyTrait" { 0:0 0:27 } {} "" {} }"#); + test_describe_structure("impl MyTrait { type N= fmt::Display; fn xx(){} const foo :u32 = 3; } ", +r#"Impl { "MyTrait" { 0:0 0:75 } {} "" {} + TypeAlias { "N" { 0:22 0:43 } {} "" {} } + Function { "xx" { 0:44 0:53 } {} "()" {} } + Var { "foo" { 0:54 0:73 } {} "" {} } +}"#); + */ + + test_describe_structure("use blah;", r#"Use { "blah" { 0:0 0:9 } {} "" {} }"#); + test_describe_structure("use blah as foo;", r#"Use { "blah as foo" { 0:0 0:16 } {} "" {} }"#); + // TODO: this is not printing the global path prefix, seems to be a limitation from libsyntax? + test_describe_structure("use ::blah::foo as myfoo;", r#"Use { "::blah::foo as myfoo" { 0:0 0:25 } {} "" {} }"#); + test_describe_structure("use ::blah::foo::*;", r#"Use { "::blah::foo::*" { 0:0 0:19 } {} "" {} }"#); + test_describe_structure("use blah::foo:: { One as OtherOne, self as Two };", r#"Use { "blah::foo::{ One as OtherOne, self as Two, }" { 0:0 0:49 } {} "" {} }"#); + + test_describe_structure("my_macro!(asf); ", ""); + + // test: visit_mac! visit method + test_describe_structure("fn foo() { my_macro!(asf); }", r#"Function { "foo" { 0:0 0:28 } {} "()" {} }"#); + + test_describe_structure("macro_rules! foo { (x => $e:expr) => (); }", r#""#); + // TODO: macro definitions, unfortunately can't get that info easily from syntax_syntex + // test_describe_structure("macro_rules! five_times { ($x:expr) => (5 * $x); }", + // r#"Macro { "foo" { 0:0 0:28 } {} "" {} }"#); + + // Test pub extern + test_describe_structure("pub extern crate my_crate;", r#"ExternCrate { "my_crate" { 0:0 0:26 } {} "" {} }"#); + + test_describe_structure( + "extern { fn ext(p : u32); }", + r#"Mod { "" { 0:0 0:27 } {} "" {} + Function { "ext" { 0:9 0:25 } {} "" {} } +}"#, + ); + test_describe_structure( + "extern { fn ext(p : u32); \n static extVar: u8; }", + r#"Mod { "" { 0:0 1:21 } {} "" {} + Function { "ext" { 0:9 0:25 } {} "" {} } + Var { "extVar" { 1:1 1:19 } {} "" {} } +}"#, + ); + + // Test with a lexer error, + // test_describe_structure("const xx : u32 = '", r#"Var { "xx" { 1 0 1 19 } {} {} {} }"#); +} diff --git a/src/token_writer.rs b/src/token_writer.rs index 3dabae1..5f2ccd0 100644 --- a/src/token_writer.rs +++ b/src/token_writer.rs @@ -1,115 +1,115 @@ -// Copyright 2015 Bruno Medeiros -// -// 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. - -use util::core::*; - -use std::fmt; -use std::result; - -pub use std::cell::{RefCell, RefMut}; -pub use std::rc::Rc; - -/// Write a parse structure into a serialized format -pub struct TokenWriter { - pub out: Rc>, -} - -impl fmt::Debug for TokenWriter { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.write_str("[TokenWriter]") - } -} - -impl TokenWriter { - pub fn get_output(&self) -> RefMut { - self.out.borrow_mut() - } - - pub fn write_raw(&mut self, string: &str) -> result::Result<(), fmt::Error> { - self.get_output().write_str(string) - } - - pub fn write_string_token(&mut self, string: &str) -> result::Result<(), fmt::Error> { - try!(write_escaped_string(string, &mut *self.get_output())); - - self.get_output().write_char(' ') - } - - pub fn write_raw_token(&mut self, string: &str) -> Void { - for ch in string.chars() { - if ch.is_whitespace() || ch == '{' || ch == '}' || ch == '(' || ch == ')' || ch == '[' || ch == ']' { - return Err("Cannot write raw token".into()); - } - } - - try!(self.get_output().write_str(string)); - try!(self.get_output().write_char(' ')); - - Ok(()) - } -} - -#[test] -fn test__write_raw_token() { - fn write_raw_token_toString(string: &str) -> GResult { - let outRc: Rc> = Rc::new(RefCell::new(String::new())); - - let result = TokenWriter { out: outRc.clone() }.write_raw_token(string); - match result { - Ok(_) => Ok(unwrap_Rc_RefCell(outRc)), - Err(error) => Err(error), - } - } - - assert_eq!(write_raw_token_toString("blah").ok().unwrap(), r#"blah "#); - write_raw_token_toString("bl ah").unwrap_err(); - write_raw_token_toString("bl{ah").unwrap_err(); -} - -/* ----------------- some parser/serialize utils ----------------- */ - -pub fn write_escaped_string(string: &str, out: &mut OUT) -> fmt::Result -//pub fn write_string_token>(string : &str, out : &mut OUT) -// -> result::Result<(), ERR> -{ - try!(out.write_char('"')); - - for ch in string.chars() { - if ch == '"' || ch == '\\' { - try!(out.write_char('\\')); - } - try!(out.write_char(ch)); - } - - try!(out.write_char('"')); - - Ok(()) -} - -#[test] -fn test__write_escaped_string() { - fn write_string_token_toString(string: &str) -> String { - let mut result = String::new(); - write_escaped_string(string, &mut result).unwrap(); - result - } - - assert_eq!(write_string_token_toString(""), r#""""#); - assert_eq!(write_string_token_toString("abc"), r#""abc""#); - assert_eq!(write_string_token_toString(r#"-"-"#), r#""-\"-""#); - assert_eq!(write_string_token_toString(r#"""#), r#""\"""#); - assert_eq!(write_string_token_toString(r#"\"#), r#""\\""#); - assert_eq!(write_string_token_toString(r#"--\"-"#), r#""--\\\"-""#); - assert_eq!(write_string_token_toString(r#"---\"#), r#""---\\""#); -} +// Copyright 2015 Bruno Medeiros +// +// 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. + +use crate::util::core::*; + +use std::fmt; +use std::result; + +pub use std::cell::{RefCell, RefMut}; +pub use std::rc::Rc; + +/// Write a parse structure into a serialized format +pub struct TokenWriter { + pub out: Rc>, +} + +impl fmt::Debug for TokenWriter { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.write_str("[TokenWriter]") + } +} + +impl TokenWriter { + pub fn get_output(&self) -> RefMut { + self.out.borrow_mut() + } + + pub fn write_raw(&mut self, string: &str) -> result::Result<(), fmt::Error> { + self.get_output().write_str(string) + } + + pub fn write_string_token(&mut self, string: &str) -> result::Result<(), fmt::Error> { + write_escaped_string(string, &mut *self.get_output())?; + + self.get_output().write_char(' ') + } + + pub fn write_raw_token(&mut self, string: &str) -> Void { + for ch in string.chars() { + if ch.is_whitespace() || ch == '{' || ch == '}' || ch == '(' || ch == ')' || ch == '[' || ch == ']' { + return Err("Cannot write raw token".into()); + } + } + + self.get_output().write_str(string)?; + self.get_output().write_char(' ')?; + + Ok(()) + } +} + +#[test] +fn test__write_raw_token() { + fn write_raw_token_toString(string: &str) -> GResult { + let outRc: Rc> = Rc::new(RefCell::new(String::new())); + + let result = TokenWriter { out: outRc.clone() }.write_raw_token(string); + match result { + Ok(_) => Ok(unwrap_Rc_RefCell(outRc)), + Err(error) => Err(error), + } + } + + assert_eq!(write_raw_token_toString("blah").ok().unwrap(), r#"blah "#); + write_raw_token_toString("bl ah").unwrap_err(); + write_raw_token_toString("bl{ah").unwrap_err(); +} + +/* ----------------- some parser/serialize utils ----------------- */ + +pub fn write_escaped_string(string: &str, out: &mut OUT) -> fmt::Result +//pub fn write_string_token>(string : &str, out : &mut OUT) +// -> result::Result<(), ERR> +{ + out.write_char('"')?; + + for ch in string.chars() { + if ch == '"' || ch == '\\' { + out.write_char('\\')?; + } + out.write_char(ch)?; + } + + out.write_char('"')?; + + Ok(()) +} + +#[test] +fn test__write_escaped_string() { + fn write_string_token_toString(string: &str) -> String { + let mut result = String::new(); + write_escaped_string(string, &mut result).unwrap(); + result + } + + assert_eq!(write_string_token_toString(""), r#""""#); + assert_eq!(write_string_token_toString("abc"), r#""abc""#); + assert_eq!(write_string_token_toString(r#"-"-"#), r#""-\"-""#); + assert_eq!(write_string_token_toString(r#"""#), r#""\"""#); + assert_eq!(write_string_token_toString(r#"\"#), r#""\\""#); + assert_eq!(write_string_token_toString(r#"--\"-"#), r#""--\\\"-""#); + assert_eq!(write_string_token_toString(r#"---\"#), r#""---\\""#); +} From 6d4c171cd553acb33060e65b3c140e1034f659cb Mon Sep 17 00:00:00 2001 From: Serhii Plyhun Date: Fri, 13 May 2022 14:09:35 +0200 Subject: [PATCH 7/7] 1.62.0 --- Cargo.lock | 1030 ++++++++++++++++++++++++++------------ Cargo.toml | 8 +- src/lib.rs | 10 +- src/parse_describe.rs | 113 +++-- src/source_model.rs | 5 +- src/structure_visitor.rs | 141 ++---- 6 files changed, 820 insertions(+), 487 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 62ad2a3..9ae0e3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,655 +1,1051 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "annotate-snippets" -version = "0.6.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78ea013094e5ea606b1c05fe35f1dd7ea1eb1ea259908d040b25bd5ec677ee5" [[package]] -name = "arena" -version = "0.0.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" -dependencies = [ - "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "atty" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "winapi", ] [[package]] name = "autocfg" -version = "0.1.7" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] -name = "byteorder" -version = "1.3.2" +name = "block-buffer" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "cloudabi" -version = "0.0.3" +name = "cpufeatures" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] -name = "crossbeam-deque" -version = "0.7.2" +name = "crypto-common" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" dependencies = [ - "crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array", + "typenum", ] [[package]] -name = "crossbeam-epoch" -version = "0.8.0" +name = "digest" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer", + "crypto-common", ] [[package]] -name = "crossbeam-queue" -version = "0.1.2" +name = "ena" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log", ] [[package]] -name = "crossbeam-utils" -version = "0.6.6" +name = "fastrand" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "instant", ] [[package]] -name = "crossbeam-utils" -version = "0.7.0" +name = "fluent-bundle" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e242c601dec9711505f6d5bbff5bedd4b61b2469f2e8bb8e57ee7c9747a87ffd" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fluent-langneg", + "fluent-syntax", + "intl-memoizer", + "intl_pluralrules", + "rustc-hash", + "self_cell", + "smallvec", + "unic-langid", ] [[package]] -name = "either" -version = "1.5.3" +name = "fluent-langneg" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ad0989667548f06ccd0e306ed56b61bd4d35458d54df5ec7587c0e8ed5e94" +dependencies = [ + "unic-langid", +] [[package]] -name = "ena" -version = "0.13.1" +name = "fluent-syntax" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0abed97648395c902868fee9026de96483933faa54ea3b40d652f7dfe61ca78" +dependencies = [ + "thiserror", +] + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getopts" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width", ] [[package]] name = "getrandom" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10", + "libc", + "wasi", ] [[package]] -name = "graphviz" -version = "0.0.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" [[package]] -name = "hermit-abi" -version = "0.1.3" +name = "indexmap" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "hashbrown", ] [[package]] -name = "indexmap" -version = "1.3.0" +name = "instant" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0", ] [[package]] -name = "itertools" -version = "0.8.1" +name = "intl-memoizer" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c310433e4a310918d6ed9243542a6b83ec1183df95dff8f23f87bb88a264a66f" dependencies = [ - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "type-map", + "unic-langid", ] [[package]] -name = "jobserver" -version = "0.1.17" +name = "intl_pluralrules" +version = "7.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b18f988384267d7066cc2be425e6faf352900652c046b6971d2e228d3b1c5ecf" dependencies = [ - "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tinystr", + "unic-langid", ] [[package]] -name = "kernel32-sys" -version = "0.2.2" +name = "jobserver" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom", + "libc", + "log", ] [[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.65" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" [[package]] name = "lock_api" -version = "0.3.1" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" dependencies = [ - "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "scopeguard", ] [[package]] name = "log" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "md-5" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658646b21e0b72f7866c7038ab086d3d5e1cd6271f060fd37defb241949d0582" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "digest", ] [[package]] -name = "maybe-uninit" -version = "2.0.0" +name = "measureme" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd460fad6e55ca82fa0cd9dab0d315294188fd9ec6efbf4105e5635d4872ef9c" +dependencies = [ + "log", + "memmap2", + "parking_lot", + "perf-event-open-sys", + "rustc-hash", + "smallvec", +] [[package]] -name = "memoffset" -version = "0.5.2" +name = "memmap2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" dependencies = [ - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] -name = "num_cpus" -version = "1.11.0" +name = "odht" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a518809ac14b25b569624d0268eba1e88498f71615893dca57982bed7621abb" dependencies = [ - "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0", ] [[package]] name = "parking_lot" -version = "0.9.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ - "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "instant", + "lock_api", + "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.6.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", ] +[[package]] +name = "perf-event-open-sys" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce9bedf5da2c234fdf2391ede2b90fabf585355f33100689bc364a3ea558561a" +dependencies = [ + "libc", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + [[package]] name = "proc-macro2" -version = "1.0.6" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid", +] + +[[package]] +name = "psm" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "871372391786ccec00d3c5d3d6608905b3d4db263639cfe075d3b60a736d115a" +dependencies = [ + "cc", ] [[package]] name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "rainicorn" version = "3.0.0" dependencies = [ - "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "rustc_errors 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syntax 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "syntax_pos 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "rustc_ast", + "rustc_ast_pretty", + "rustc_data_structures", + "rustc_error_messages", + "rustc_errors", + "rustc_parse", + "rustc_session", + "rustc_span", + "rustdt_util", ] [[package]] name = "redox_syscall" -version = "0.1.56" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +dependencies = [ + "bitflags", +] [[package]] -name = "rustc-hash" -version = "1.0.1" +name = "remove_dir_all" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] [[package]] -name = "rustc-rayon" -version = "0.3.0" +name = "rustc-hash" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_arena" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" dependencies = [ - "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-rayon-core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec", ] [[package]] -name = "rustc-rayon-core" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "rustc_ast" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" dependencies = [ - "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "rustc_data_structures", + "rustc_index", + "rustc_lexer", + "rustc_macros", + "rustc_serialize", + "rustc_span", + "smallvec", + "tracing", +] + +[[package]] +name = "rustc_ast_pretty" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" +dependencies = [ + "rustc_ast", + "rustc_span", ] [[package]] name = "rustc_data_structures" version = "0.0.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", - "graphviz 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-rayon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-rayon-core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_index 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" +dependencies = [ + "arrayvec", + "bitflags", + "cfg-if 0.1.10", + "ena", + "indexmap", + "jobserver", + "libc", + "measureme", + "memmap2", + "parking_lot", + "rustc-hash", + "rustc_graphviz", + "rustc_index", + "rustc_macros", + "rustc_serialize", + "smallvec", + "stable_deref_trait", + "stacker", + "tempfile", + "tracing", + "winapi", +] + +[[package]] +name = "rustc_error_messages" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" +dependencies = [ + "fluent-bundle", + "fluent-syntax", + "intl-memoizer", + "rustc_data_structures", + "rustc_macros", + "rustc_serialize", + "rustc_span", + "tracing", + "unic-langid", ] [[package]] name = "rustc_errors" version = "0.0.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" +dependencies = [ + "annotate-snippets", + "atty", + "rustc_data_structures", + "rustc_error_messages", + "rustc_lint_defs", + "rustc_macros", + "rustc_serialize", + "rustc_span", + "termcolor", + "termize", + "tracing", + "unicode-width", + "winapi", +] + +[[package]] +name = "rustc_feature" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" dependencies = [ - "annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "syntax_pos 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_data_structures", + "rustc_span", +] + +[[package]] +name = "rustc_fs_util" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" + +[[package]] +name = "rustc_graphviz" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" + +[[package]] +name = "rustc_hir" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" +dependencies = [ + "odht", + "rustc_ast", + "rustc_data_structures", + "rustc_error_messages", + "rustc_feature", + "rustc_index", + "rustc_macros", + "rustc_serialize", + "rustc_span", + "rustc_target", + "smallvec", + "tracing", ] [[package]] name = "rustc_index" version = "0.0.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" dependencies = [ - "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec", + "rustc_macros", + "rustc_serialize", + "smallvec", ] [[package]] name = "rustc_lexer" version = "0.1.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" +dependencies = [ + "unic-emoji-char", + "unicode-xid", +] + +[[package]] +name = "rustc_lint_defs" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_ast", + "rustc_data_structures", + "rustc_error_messages", + "rustc_hir", + "rustc_macros", + "rustc_serialize", + "rustc_span", + "rustc_target", ] [[package]] name = "rustc_macros" version = "0.1.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" dependencies = [ - "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", + "synstructure", ] [[package]] -name = "rustc_target" +name = "rustc_parse" version = "0.0.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "rustc_index 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "syntax_pos 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "bitflags", + "rustc_ast", + "rustc_ast_pretty", + "rustc_data_structures", + "rustc_errors", + "rustc_feature", + "rustc_lexer", + "rustc_macros", + "rustc_session", + "rustc_span", + "tracing", + "unicode-normalization", + "unicode-width", ] [[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "rustc_serialize" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" +dependencies = [ + "indexmap", + "smallvec", +] + +[[package]] +name = "rustc_session" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts", + "rustc_ast", + "rustc_data_structures", + "rustc_errors", + "rustc_feature", + "rustc_fs_util", + "rustc_hir", + "rustc_lint_defs", + "rustc_macros", + "rustc_serialize", + "rustc_span", + "rustc_target", + "tracing", +] + +[[package]] +name = "rustc_span" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" +dependencies = [ + "cfg-if 0.1.10", + "md-5", + "rustc_arena", + "rustc_data_structures", + "rustc_index", + "rustc_macros", + "rustc_serialize", + "scoped-tls", + "sha-1", + "sha2", + "tracing", + "unicode-width", +] + +[[package]] +name = "rustc_target" +version = "0.0.0" +source = "git+https://github.com/snuk182/rustc-syntax-tools#d8017548a66814a37014d6481637c3a082797e1e" +dependencies = [ + "bitflags", + "rustc_data_structures", + "rustc_index", + "rustc_macros", + "rustc_serialize", + "rustc_span", + "tracing", ] [[package]] name = "rustdt_util" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cfffa8a89d8758be2dd5605c5fc62bce055af2491ebf3ce953d4d31512c59fd" [[package]] name = "scoped-tls" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" [[package]] name = "scopeguard" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] -name = "semver" -version = "0.9.0" +name = "self_cell" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] +checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af" [[package]] -name = "semver-parser" -version = "0.7.0" +name = "sha-1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serialize" -version = "0.0.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" dependencies = [ - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0", + "cpufeatures", + "digest", ] [[package]] -name = "smallvec" -version = "0.6.13" +name = "sha2" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" dependencies = [ - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0", + "cpufeatures", + "digest", ] [[package]] name = "smallvec" -version = "1.0.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "stable_deref_trait" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" + +[[package]] +name = "stacker" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90939d5171a4420b3ff5fbc8954d641e7377335454c259dcb80786f3f21dc9b4" +dependencies = [ + "cc", + "cfg-if 1.0.0", + "libc", + "psm", + "winapi", +] [[package]] name = "syn" -version = "1.0.7" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04066589568b72ec65f42d65a1a52436e954b168773148893c020269563decf2" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] name = "synstructure" version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "575be94ccb86e8da37efb894a87e2b660be299b41d8ef347f9d6d79fbe61b1ba" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", + "unicode-xid", ] [[package]] -name = "syntax" -version = "0.0.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "rustc_errors 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "rustc_index 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "rustc_lexer 0.1.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "rustc_target 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntax_pos 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", + "cfg-if 1.0.0", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", ] [[package]] -name = "syntax_pos" -version = "0.0.0" -source = "git+https://github.com/snuk182/rustc-syntax-tools#16e80df10530f6142d241187385cce586e6822fb" +name = "termcolor" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" dependencies = [ - "arena 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "rustc_index 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "rustc_macros 0.1.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)", - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "wincolor", ] [[package]] -name = "term_size" -version = "0.3.1" +name = "termize" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1706be6b564323ce7092f5f7e6b118a14c8ef7ed0e69c8c5329c914a9f101295" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "winapi", ] [[package]] -name = "termcolor" -version = "1.0.5" +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29738eedb4388d9ea620eeab9384884fc3f06f586a2eddb56bedc5885126c7c1" + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tracing" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "type-map" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d3364c5e96cb2ad1603037ab253ddd34d7fb72a58bdddf4b7350760fc69a46" +dependencies = [ + "rustc-hash", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unic-char-property" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" +dependencies = [ + "unic-char-range", +] + +[[package]] +name = "unic-char-range" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" + +[[package]] +name = "unic-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" + +[[package]] +name = "unic-emoji-char" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b07221e68897210270a38bde4babb655869637af0f69407f96053a34f76494d" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-langid" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73328fcd730a030bdb19ddf23e192187a6b01cd98be6d3140622a89129459ce5" +dependencies = [ + "unic-langid-impl", + "unic-langid-macros", +] + +[[package]] +name = "unic-langid-impl" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a4a8eeaf0494862c1404c95ec2f4c33a2acff5076f64314b465e3ddae1b934d" dependencies = [ - "wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tinystr", +] + +[[package]] +name = "unic-langid-macros" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18f980d6d87e8805f2836d64b4138cc95aa7986fa63b1f51f67d5fbff64dd6e5" +dependencies = [ + "proc-macro-hack", + "tinystr", + "unic-langid-impl", + "unic-langid-macros-impl", +] + +[[package]] +name = "unic-langid-macros-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29396ffd97e27574c3e01368b1a64267d3064969e4848e2e130ff668be9daa9f" +dependencies = [ + "proc-macro-hack", + "quote", + "syn", + "unic-langid-impl", +] + +[[package]] +name = "unic-ucd-version" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" +dependencies = [ + "unic-common", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", ] [[package]] name = "unicode-width" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" [[package]] name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" [[package]] -name = "wasi" -version = "0.7.0" +name = "version_check" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] -name = "winapi" -version = "0.2.8" +name = "wasi" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" [[package]] name = "winapi" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[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.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "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" [[package]] name = "wincolor" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7021ce4924a3f25f802b2cccd1af585e39ea1a363a1aa2e72afe54b67a3a7a7" -"checksum arena 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" -"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" -"checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" -"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" -"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -"checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" -"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -"checksum ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36" -"checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" -"checksum graphviz 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" -"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" -"checksum itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "87fa75c9dea7b07be3138c49abbb83fd4bea199b5cdc76f9804458edc5da0d6e" -"checksum jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" -"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" -"checksum memoffset 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a85c1a8c329f11437034d7313dca647c79096523533a1c79e86f1d0f657c7cc" -"checksum num_cpus 1.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "155394f924cdddf08149da25bfb932d226b4a593ca7468b08191ff6335941af5" -"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" -"checksum rustc-rayon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f32767f90d938f1b7199a174ef249ae1924f6e5bbdb9d112fea141e016f25b3a" -"checksum rustc-rayon-core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea2427831f0053ea3ea73559c8eabd893133a51b251d142bacee53c62a288cb3" -"checksum rustc_data_structures 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum rustc_errors 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum rustc_index 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum rustc_lexer 0.1.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum rustc_macros 0.1.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum rustc_target 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rustdt_util 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7cfffa8a89d8758be2dd5605c5fc62bce055af2491ebf3ce953d4d31512c59fd" -"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" -"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serialize 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -"checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" -"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" -"checksum syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7bedb3320d0f3035594b0b723c8a28d7d336a3eda3881db79e61d676fb644c" -"checksum synstructure 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "575be94ccb86e8da37efb894a87e2b660be299b41d8ef347f9d6d79fbe61b1ba" -"checksum syntax 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum syntax_pos 0.0.0 (git+https://github.com/snuk182/rustc-syntax-tools)" = "" -"checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" -"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" -"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" + "winapi", + "winapi-util", +] diff --git a/Cargo.toml b/Cargo.toml index dcc97bc..fe6c10a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,9 +6,13 @@ edition = "2018" [dependencies] rustc_errors = { git = "https://github.com/snuk182/rustc-syntax-tools" } +rustc_error_messages = { git = "https://github.com/snuk182/rustc-syntax-tools" } rustc_data_structures = { git = "https://github.com/snuk182/rustc-syntax-tools" } -syntax = { git = "https://github.com/snuk182/rustc-syntax-tools" } -syntax_pos = { git = "https://github.com/snuk182/rustc-syntax-tools" } +rustc_span = { git = "https://github.com/snuk182/rustc-syntax-tools" } +rustc_session = { git = "https://github.com/snuk182/rustc-syntax-tools" } +rustc_ast = { git = "https://github.com/snuk182/rustc-syntax-tools" } +rustc_ast_pretty = { git = "https://github.com/snuk182/rustc-syntax-tools" } +rustc_parse = { git = "https://github.com/snuk182/rustc-syntax-tools" } rustdt_util ="0.2.3" [[bin]] diff --git a/src/lib.rs b/src/lib.rs index 53c81f1..9f8c1ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,14 @@ #![allow(non_snake_case)] use rustdt_util as util; -use rustc_errors as syntex_errors; +use rustc_errors; use rustc_data_structures; -use syntax as syntex_syntax; -use syntax_pos as syntex_pos; +use rustc_span; +use rustc_error_messages; +use rustc_session; +use rustc_ast; +use rustc_ast_pretty; +use rustc_parse; pub mod parse_describe; pub mod source_model; diff --git a/src/parse_describe.rs b/src/parse_describe.rs index 39fa00e..d229db1 100644 --- a/src/parse_describe.rs +++ b/src/parse_describe.rs @@ -18,27 +18,25 @@ use crate::source_model::*; use crate::util::core::*; use crate::util::string::*; -use crate::syntex_errors::emitter; -use crate::syntex_errors::{SourceMapperDyn, Diagnostic, Handler, Level, DiagnosticId}; -use crate::syntex_syntax::source_map::{self, SourceMap, FilePathMapping, MultiSpan}; -use crate::syntex_syntax::parse; -use crate::syntex_syntax::sess::ParseSess; -use crate::syntex_syntax::ast; -use crate::syntex_syntax::edition; -use crate::syntex_syntax::tokenstream::TokenStream; -use crate::syntex_syntax::visit; -use crate::syntex_pos::FileName; +use crate::rustc_errors::emitter; +use crate::rustc_errors::{Diagnostic, Handler, Level, DiagnosticId, PResult, DiagnosticMessage, FluentBundle, LazyFallbackBundle, DEFAULT_LOCALE_RESOURCES, fallback_fluent_bundle}; +use crate::rustc_span::source_map::{self, SourceMap, FilePathMapping, FileName}; +use crate::rustc_error_messages::MultiSpan; +use crate::rustc_session::parse::{ParseSess}; +use crate::rustc_parse as parse; +use crate::rustc_ast::ast; +use crate::rustc_span::{SourceFileHashAlgorithm, RealFileName}; +use crate::rustc_ast::tokenstream::TokenStream; +use crate::rustc_ast::visit; use crate::rustc_data_structures::sync::Lrc; use std::boxed::Box; use std::path::Path; use std::cell::RefCell; -use std::env; use std::fmt; use std::io; use std::io::Write; -use std::path::PathBuf; use std::rc::*; /* ----------------- ----------------- */ @@ -64,12 +62,10 @@ use std::thread; pub fn parse_crate_with_messages(source: &str) -> (Vec, Vec) { let messages = Arc::new(Mutex::new(vec![])); let elements = { - use crate::syntex_syntax::with_globals; - - let source = String::from(source); + let source = String::from(source); let messages = messages.clone(); - let worker_thread = thread::Builder::new().name("parser_thread".to_string()).spawn(move || with_globals(edition::DEFAULT_EDITION, || parse_crate_with_messages_do(&source, messages))).unwrap(); + let worker_thread = thread::Builder::new().name("parser_thread".to_string()).spawn(move || parse_crate_with_messages_do(&source, messages)).unwrap(); worker_thread.join().unwrap_or(vec![]) }; @@ -86,7 +82,7 @@ pub fn parse_crate_with_messages_do(source: &str, messages: Arc Option { - if path.is_absolute() { - Some(path.to_path_buf()) - } else { - env::current_dir().ok().map(|cwd| cwd.join(path)) - } - } - fn read_file(&self, _path: &Path) -> io::Result { Ok(String::new()) } } struct MessagesHandler { - codemap: Rc, + codemap: Rc, messages: Arc>>, + fallback_fluent_bundle: LazyFallbackBundle, } fn parse_crate<'a>(source: &str, codemap: Rc, messages: Arc>>) -> Option { @@ -154,24 +143,24 @@ fn parse_crate<'a>(source: &str, codemap: Rc, messages: Arc(source: &str, sess: &'a ParseSess) -> parse::PResult<'a, ast::Crate> { +pub fn parse_crate_do<'a>(source: &str, sess: &'a ParseSess) -> PResult<'a, ast::Crate> { use std::iter::FromIterator; let source = source.to_string(); let name = "_file_module_".to_string(); let tts = { - let mut p1 = parse::new_parser_from_source_str(sess, FileName::Real(name.into()), source); + let mut p1 = parse::new_parser_from_source_str(sess, FileName::Real(RealFileName::LocalPath(name.into())), source); p1.parse_all_token_trees()?.into_iter().map(|tt| tt.into()).collect::>() }; - let mut parser = parse::parser::Parser::new(sess, TokenStream::from_iter(tts), None, true, false, None); + let mut parser = parse::parser::Parser::new(sess, TokenStream::from_iter(tts), true, None); parser.parse_crate_mod() } impl MessagesHandler { - fn new(codemap: Rc, messages: Arc>>) -> MessagesHandler { - MessagesHandler { codemap: codemap, messages: messages } + fn new(codemap: Rc, messages: Arc>>) -> MessagesHandler { + MessagesHandler { codemap: codemap, messages: messages, fallback_fluent_bundle: fallback_fluent_bundle(DEFAULT_LOCALE_RESOURCES, false) } } fn write_message_handled(&mut self, sourcerange: Option, msg: &str, severity: Severity) { @@ -188,40 +177,50 @@ impl MessagesHandler { impl emitter::Emitter for MessagesHandler { fn emit_diagnostic(&mut self, db: &Diagnostic) { - let msg = db.message(); - let msg = msg.as_str(); - let code: Option<&String> = db.code.as_ref().map(|c| match c { - DiagnosticId::Error(ref str) => str, - DiagnosticId::Lint(ref str) => str, - }); - let lvl: Level = db.level; - - let multispan: &MultiSpan = &db.span; - - if let Some(code) = code { - io::stderr().write_fmt(format_args!("Code: {}\n", code)).unwrap(); - panic!("What is code: Option<&str>??"); - } + for ref msg in db.message.as_slice() { + let msg = match &msg.0 { + DiagnosticMessage::Str(ref str) => str.clone(), + DiagnosticMessage::FluentIdentifier(id, _) => format!("FluentID: {}", id), + }; + let code: Option<&String> = db.code.as_ref().map(|c| match c { + DiagnosticId::Error(ref str) => str, + DiagnosticId::Lint {ref name, ..} => name, + }); + let lvl: Level = db.level(); + + let multispan: &MultiSpan = &db.span; + + if let Some(code) = code { + io::stderr().write_fmt(format_args!("Code: {}\n", code)).unwrap(); + panic!("What is code: Option<&str>??"); + } + + let sourceranges: Vec<_> = multispan.primary_spans().iter().map(|span| -> SourceRange { SourceRange::new(self.codemap.as_ref(), *span) }).collect(); + + for sourcerange in sourceranges { + self.write_message_handled(Some(sourcerange), msg.as_str(), level_to_status_level(lvl)); + } + } + } - let sourceranges: Vec<_> = multispan.primary_spans().iter().map(|span| -> SourceRange { SourceRange::new(self.codemap.as_ref(), *span) }).collect(); + fn fluent_bundle(&self) -> Option<&Lrc> { None } - for sourcerange in sourceranges { - self.write_message_handled(Some(sourcerange), msg, level_to_status_level(lvl)); - } - } - - fn source_map(&self) -> Option<&Lrc> { + fn fallback_fluent_bundle(&self) -> &FluentBundle { + &**self.fallback_fluent_bundle + } + + fn source_map(&self) -> Option<&Lrc> { Some(&self.codemap) } } fn level_to_status_level(lvl: Level) -> Severity { match lvl { - Level::Bug => panic!("Level::BUG"), - Level::Cancelled => panic!("Level::CANCELLED"), - Level::Help | Level::Note => Severity::INFO, - Level::Warning | Level::FailureNote => Severity::WARNING, - Level::Error | Level::Fatal => Severity::ERROR, + Level::Bug | Level::DelayedBug => panic!("Level::BUG"), + Level::Help | Level::Note | Level::OnceNote | Level::Allow => Severity::INFO, + Level::Warning | Level::FailureNote | Level::Expect(_) => Severity::WARNING, + Level::Fatal => Severity::ERROR, + Level::Error {lint} => if lint {Severity::WARNING} else {Severity::ERROR} } } diff --git a/src/source_model.rs b/src/source_model.rs index 4461532..ca3422d 100644 --- a/src/source_model.rs +++ b/src/source_model.rs @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::syntex_syntax::source_map::{CharPos, Loc, Span}; -use crate::syntex_errors::{SourceMapperDyn}; +use crate::rustc_span::source_map::{CharPos, Loc, Span, SourceMap}; #[derive(Debug, Clone, Copy)] pub struct LineColumnPosition { @@ -30,7 +29,7 @@ pub struct SourceRange { } impl SourceRange { - pub fn new(codemap: &SourceMapperDyn, span: Span) -> SourceRange { + pub fn new(codemap: &SourceMap, span: Span) -> SourceRange { let startLoc = codemap.lookup_char_pos(span.lo()); let endLoc = codemap.lookup_char_pos(span.hi()); diff --git a/src/structure_visitor.rs b/src/structure_visitor.rs index 92ef1b8..8e76584 100644 --- a/src/structure_visitor.rs +++ b/src/structure_visitor.rs @@ -19,9 +19,12 @@ use crate::source_model::*; use crate::util::core::*; -use crate::syntex_syntax::ast::*; -use crate::syntex_syntax::source_map::{SourceMap, Span}; -use crate::syntex_syntax::visit::*; +use crate::rustc_ast::ast::*; +use crate::rustc_span::source_map::{SourceMap, Span}; +use crate::rustc_span::symbol::{Symbol, Ident}; +use crate::rustc_ast::visit::*; + +use std::ops::Fn; pub struct StructureVisitor<'ps> { pub codemap: &'ps SourceMap, @@ -40,6 +43,10 @@ impl<'ps> StructureVisitor<'ps> { } } + fn visit_mac(&mut self, mac: &'ps MacCall) { + walk_mac(self, mac) + } + pub fn write_element_do(&mut self, ident: &str, kind: StructureElementKind, sourcerange: SourceRange, type_desc: String, walkFn: FN) -> Void where FN: Fn(&mut Self), @@ -96,8 +103,8 @@ impl<'ps> StructureVisitor<'ps> { fn write_ItemUse(&mut self, tree: &UseTree) { use std::ops::Index; - use crate::syntex_syntax::ast; - use crate::syntex_syntax::print::pprust; + use crate::rustc_ast::ast; + use crate::rustc_ast_pretty::pprust; let kind = StructureElementKind::Use; let mut useSpec = String::new(); @@ -170,7 +177,7 @@ impl<'ps> StructureVisitor<'ps> { } type_desc.push_str(")"); - if let FunctionRetTy::Ty(ref _ret) = fd.output { + if let FnRetTy::Ty(ref _ret) = fd.output { if let Ok(ret_snippet) = self.codemap.span_to_snippet(fd.output.span()) { type_desc.push_str(" -> "); type_desc.push_str(&ret_snippet); @@ -188,21 +195,13 @@ impl<'ps> StructureVisitor<'ps> { } impl<'v> Visitor<'v> for StructureVisitor<'v> { - fn visit_name(&mut self, _span: Span, _name: Name) { + fn visit_name(&mut self, _span: Span, _name: Symbol) { // Nothing to do. } fn visit_ident(&mut self, ident: Ident) { walk_ident(self, ident); } - fn visit_mod(&mut self, m: &'v Mod, _span: Span, _attrs: &[Attribute], _nodeid: NodeId) { - // let sr = &SourceRange::new(self.codemap, span); - // self.write_element_handled("_file_", StructureElementKind::File, sr, |_self : &mut Self| { - // walk_mod(_self, m); - // }) - walk_mod(self, m); - } - fn visit_item(&mut self, item: &'v Item) { let kind; let mut type_desc = "".to_string(); @@ -214,8 +213,9 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { }; match item.kind { - ItemKind::OpaqueTy(ref _bounds, ref _generics) => { - kind = StructureElementKind::OpaqueTy; + ItemKind::GlobalAsm(ref asm) => { + self.visit_inline_asm(asm); + return; } ItemKind::TraitAlias(ref _generics, ref _bounds) => { kind = StructureElementKind::TraitAlias; @@ -227,30 +227,30 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { self.write_ItemUse(vp); return; } - ItemKind::Static(ref typ, _, ref _expr) | ItemKind::Const(ref typ, ref _expr) => { + ItemKind::Static(ref typ, _, ref _expr) | ItemKind::Const(_, ref typ, ref _expr) => { if let Ok(snippet) = self.codemap.span_to_snippet(typ.span) { type_desc.push_str(&snippet); } self.write_element(item.ident, StructureElementKind::Var, item.span, type_desc, noop_walkFn); return; } - ItemKind::Fn(ref declaration, ref header, ref _generics, ref body) => { - self.visit_fn(FnKind::ItemFn(item.ident, header, &item.vis, body), declaration, item.span, item.id); + ItemKind::Fn(ref fn1) => { + self.visit_fn(FnKind::Fn(FnCtxt::Free, item.ident, &fn1.sig, &item.vis, &fn1.generics, fn1.body.as_ref().map(|p| &**p)), item.span, item.id); return; } - ItemKind::Mod(ref _module) => { + ItemKind::Mod(_, _) => { kind = StructureElementKind::Mod; } ItemKind::ForeignMod(ref _foreign_module) => { kind = StructureElementKind::Mod; } - ItemKind::TyAlias(ref _typ, ref _type_parameters) => { + ItemKind::TyAlias(_) => { kind = StructureElementKind::TypeAlias; } ItemKind::Enum(ref _enum_definition, ref _type_parameters) => { kind = StructureElementKind::Enum; } - ItemKind::Impl(_, _, ref _type_parameters, _, ref _opt_trait_reference, ref _typ, ref _impl_items) => { + ItemKind::Impl(_) => { kind = StructureElementKind::Impl; } ItemKind::Struct(ref _struct_definition, ref _generics) => { @@ -264,17 +264,13 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { walk_item(self, item); return; } - ItemKind::Trait(_, _, ref _generics, ref _bounds, ref _methods) => { + ItemKind::Trait(_) => { kind = StructureElementKind::Trait; } - ItemKind::Mac(ref mac) => { + ItemKind::MacCall(ref mac) => { self.visit_mac(mac); return; } - ItemKind::GlobalAsm(ref asm) => { - self.visit_global_asm(asm); - return; - } ItemKind::MacroDef(ref macro_def) => { self.visit_mac_def(macro_def, item.id); return; @@ -307,7 +303,7 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { match s { VariantData::Struct(fields, _) | VariantData::Tuple(fields, _) => { for field in fields { - self.write_element_TODO(field.ident.unwrap_or(Ident::invalid()), kind, field.span, |_self: &mut Self| { + self.write_element_TODO(field.ident.unwrap_or(Ident::empty()), kind, field.span, |_self: &mut Self| { walk_struct_def(_self, s); }); } @@ -316,84 +312,22 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { }; } - fn visit_struct_field(&mut self, sf: &'v StructField) { - if let Some(ident) = sf.ident { - self.write_element_TODO(ident, StructureElementKind::Var, sf.span, |_self: &mut Self| { - walk_struct_field(_self, sf); - }); - } - } - - fn visit_trait_item(&mut self, ti: &'v TraitItem) { - let kind; - - match ti.kind { - TraitItemKind::Const(ref _ty, ref _default) => { - kind = StructureElementKind::Var; - } - TraitItemKind::Method(ref sig, _) => { - self.write_function_element(ti.ident, ti.span, &sig.decl, &|_self: &mut Self| { - walk_trait_item(_self, ti); - }); - return; - } - TraitItemKind::Type(ref _bounds, ref _default) => { - kind = StructureElementKind::TypeAlias; - } - TraitItemKind::Macro(ref mac) => { - self.visit_mac(mac); - return; - } - } - - self.write_element_TODO(ti.ident, kind, ti.span, |_self: &mut Self| { - walk_trait_item(_self, ti); - }); - } - - fn visit_impl_item(&mut self, ii: &'v ImplItem) { - let kind; - - match ii.kind { - ImplItemKind::Const(ref _ty, ref _default) => { - kind = StructureElementKind::Var; - } - ImplItemKind::TyAlias(ref _type) => { - kind = StructureElementKind::TypeAlias; - } - ImplItemKind::Method(_, _) | ImplItemKind::Macro(_) => { - walk_impl_item(self, ii); - return; - } - ImplItemKind::OpaqueTy(_) => { - kind = StructureElementKind::OpaqueTy; - } - } - - self.write_element_TODO(ii.ident, kind, ii.span, |_self: &mut Self| { - walk_impl_item(_self, ii); - }); - } - /* ----------------- Function ----------------- */ - fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, span: Span, _nodeid: NodeId) { + fn visit_fn(&mut self, fk: FnKind<'v>, span: Span, _nodeid: NodeId) { let ident: Ident; match fk { - FnKind::Method(_ident, ref _MethodSig, _option, _b) => { - ident = _ident; - } - FnKind::ItemFn(_ident, FnHeader { asyncness: _Asyncness, unsafety: _Unsafety, constness: _Constness, abi: _Abi }, _Visibility, _b) => { - ident = _ident; + FnKind::Fn(_, ident1, ref _MethodSig, _option, _b, _) => { + ident = ident1; } - FnKind::Closure(_) => { + FnKind::Closure(_, _) => { return; } }; - self.write_function_element(ident, span, fd, &|_self: &mut Self| { - walk_fn(_self, fk, fd, span); + self.write_function_element(ident, span, fk.decl(), &|_self: &mut Self| { + walk_fn(_self, fk, span); }); } @@ -401,16 +335,16 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { let kind; match foreign_item.kind { - ForeignItemKind::Fn(ref _function_declaration, ref _generics) => { + ForeignItemKind::Fn(_) => { kind = StructureElementKind::Function; } - ForeignItemKind::Static(ref _typ, _) => { + ForeignItemKind::Static(ref _typ, _, _) => { kind = StructureElementKind::Var; } - ForeignItemKind::Ty => { + ForeignItemKind::TyAlias(_) => { kind = StructureElementKind::TypeAlias; } - ForeignItemKind::Macro(_) => { + ForeignItemKind::MacCall(_) => { kind = StructureElementKind::MacroDef; } } @@ -457,9 +391,6 @@ impl<'v> Visitor<'v> for StructureVisitor<'v> { fn visit_generics(&mut self, g: &'v Generics) { walk_generics(self, g) } - fn visit_mac(&mut self, mac: &'v Mac) { - walk_mac(self, mac) - } fn visit_path(&mut self, path: &'v Path, _id: NodeId) { walk_path(self, path) }