From 8d110483a273e88736a285bc8d109b24233f7857 Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Tue, 10 Oct 2023 21:05:00 -0600 Subject: [PATCH] Remove support for `crate` visibility modifier Dropped in rustc: https://github.com/rust-lang/rust/issues/53120#issuecomment-1124065083 --- Cargo.lock | 63 +++++++++++----------- benches/expr.rs | 4 +- peg-macros/grammar.rs | 104 +++++++++++-------------------------- peg-macros/grammar.rustpeg | 4 +- 4 files changed, 68 insertions(+), 107 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72e5e22..af0c04b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,30 +4,30 @@ version = 3 [[package]] name = "basic-toml" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0de75129aa8d0cceaf750b89013f0e08804d6ec61416da787b35ad0d7cddf1" +checksum = "7bfc506e7a2370ec239e1d072507b2a80c833083699d3c6fa176fbb4de8448c6" dependencies = [ "serde", ] [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "itoa" -version = "0.4.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "peg" @@ -54,39 +54,42 @@ version = "0.8.2" [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.26" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "serde" -version = "1.0.159" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] [[package]] name = "serde_derive" -version = "1.0.159" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", @@ -95,9 +98,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.57" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -106,9 +109,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.13" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -117,18 +120,18 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] [[package]] name = "trybuild" -version = "1.0.80" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501dbdbb99861e4ab6b60eb6a7493956a9defb644fd034bc4a5ef27c693c8a3a" +checksum = "196a58260a906cedb9bf6d8034b6379d0c11f552416960452f267402ceeddff1" dependencies = [ "basic-toml", "glob", @@ -141,9 +144,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" @@ -169,9 +172,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] diff --git a/benches/expr.rs b/benches/expr.rs index 84b3ea5..627a523 100644 --- a/benches/expr.rs +++ b/benches/expr.rs @@ -1,4 +1,4 @@ -#![feature(test, crate_visibility_modifier)] +#![feature(test)] extern crate peg; extern crate test; @@ -6,7 +6,7 @@ extern crate test; use test::Bencher; peg::parser!(grammar parser() for str { -crate rule expr() = eq() +pub(crate) rule expr() = eq() #[cache] rule eq() = additive() "=" eq() / additive() diff --git a/peg-macros/grammar.rs b/peg-macros/grammar.rs index 9803797..ca094f7 100644 --- a/peg-macros/grammar.rs +++ b/peg-macros/grammar.rs @@ -970,54 +970,31 @@ pub mod peg { #![allow(non_snake_case, unused, clippy::redundant_closure_call)] match { let str_start = __pos; - match { - let __choice_res = - match ::peg::ParseLiteral::parse_string_literal(__input, __pos, "pub") { - ::peg::RuleResult::Matched(__pos, __val) => { - let __seq_res = match match __parse_PAREN_GROUP( - __input, - __state, - __err_state, - __pos, - ) { - ::peg::RuleResult::Matched(pos, _) => { - ::peg::RuleResult::Matched(pos, ()) - } - ::peg::RuleResult::Failed => ::peg::RuleResult::Failed, - } { - ::peg::RuleResult::Matched(__newpos, _) => { - ::peg::RuleResult::Matched(__newpos, ()) - } - ::peg::RuleResult::Failed => ::peg::RuleResult::Matched(__pos, ()), - }; - match __seq_res { - ::peg::RuleResult::Matched(__pos, _) => { - ::peg::RuleResult::Matched(__pos, ()) - } - ::peg::RuleResult::Failed => ::peg::RuleResult::Failed, - } - } - ::peg::RuleResult::Failed => { - __err_state.mark_failure(__pos, "\"pub\""); - ::peg::RuleResult::Failed - } - }; - match __choice_res { - ::peg::RuleResult::Matched(__pos, __value) => { - ::peg::RuleResult::Matched(__pos, __value) - } - ::peg::RuleResult::Failed => { - match ::peg::ParseLiteral::parse_string_literal(__input, __pos, "crate") { - ::peg::RuleResult::Matched(__pos, __val) => { - ::peg::RuleResult::Matched(__pos, __val) + match match ::peg::ParseLiteral::parse_string_literal(__input, __pos, "pub") { + ::peg::RuleResult::Matched(__pos, __val) => { + let __seq_res = + match match __parse_PAREN_GROUP(__input, __state, __err_state, __pos) { + ::peg::RuleResult::Matched(pos, _) => { + ::peg::RuleResult::Matched(pos, ()) } - ::peg::RuleResult::Failed => { - __err_state.mark_failure(__pos, "\"crate\""); - ::peg::RuleResult::Failed + ::peg::RuleResult::Failed => ::peg::RuleResult::Failed, + } { + ::peg::RuleResult::Matched(__newpos, _) => { + ::peg::RuleResult::Matched(__newpos, ()) } + ::peg::RuleResult::Failed => ::peg::RuleResult::Matched(__pos, ()), + }; + match __seq_res { + ::peg::RuleResult::Matched(__pos, _) => { + ::peg::RuleResult::Matched(__pos, ()) } + ::peg::RuleResult::Failed => ::peg::RuleResult::Failed, } } + ::peg::RuleResult::Failed => { + __err_state.mark_failure(__pos, "\"pub\""); + ::peg::RuleResult::Failed + } } { ::peg::RuleResult::Matched(__newpos, _) => ::peg::RuleResult::Matched( __newpos, @@ -3172,12 +3149,12 @@ pub mod peg { } ::peg::RuleResult::Failed => { let __choice_res = - match ::peg::ParseLiteral::parse_string_literal(__input, __pos, "crate") { + match ::peg::ParseLiteral::parse_string_literal(__input, __pos, "rule") { ::peg::RuleResult::Matched(__pos, __val) => { ::peg::RuleResult::Matched(__pos, __val) } ::peg::RuleResult::Failed => { - __err_state.mark_failure(__pos, "\"crate\""); + __err_state.mark_failure(__pos, "\"rule\""); ::peg::RuleResult::Failed } }; @@ -3187,13 +3164,13 @@ pub mod peg { } ::peg::RuleResult::Failed => { let __choice_res = match ::peg::ParseLiteral::parse_string_literal( - __input, __pos, "rule", + __input, __pos, "use", ) { ::peg::RuleResult::Matched(__pos, __val) => { ::peg::RuleResult::Matched(__pos, __val) } ::peg::RuleResult::Failed => { - __err_state.mark_failure(__pos, "\"rule\""); + __err_state.mark_failure(__pos, "\"use\""); ::peg::RuleResult::Failed } }; @@ -3202,34 +3179,15 @@ pub mod peg { ::peg::RuleResult::Matched(__pos, __value) } ::peg::RuleResult::Failed => { - let __choice_res = - match ::peg::ParseLiteral::parse_string_literal( - __input, __pos, "use", - ) { - ::peg::RuleResult::Matched(__pos, __val) => { - ::peg::RuleResult::Matched(__pos, __val) - } - ::peg::RuleResult::Failed => { - __err_state.mark_failure(__pos, "\"use\""); - ::peg::RuleResult::Failed - } - }; - match __choice_res { - ::peg::RuleResult::Matched(__pos, __value) => { - ::peg::RuleResult::Matched(__pos, __value) + match ::peg::ParseLiteral::parse_string_literal( + __input, __pos, "type", + ) { + ::peg::RuleResult::Matched(__pos, __val) => { + ::peg::RuleResult::Matched(__pos, __val) } ::peg::RuleResult::Failed => { - match ::peg::ParseLiteral::parse_string_literal( - __input, __pos, "type", - ) { - ::peg::RuleResult::Matched(__pos, __val) => { - ::peg::RuleResult::Matched(__pos, __val) - } - ::peg::RuleResult::Failed => { - __err_state.mark_failure(__pos, "\"type\""); - ::peg::RuleResult::Failed - } - } + __err_state.mark_failure(__pos, "\"type\""); + ::peg::RuleResult::Failed } } } diff --git a/peg-macros/grammar.rustpeg b/peg-macros/grammar.rustpeg index 58495b3..1257617 100644 --- a/peg-macros/grammar.rustpeg +++ b/peg-macros/grammar.rustpeg @@ -43,7 +43,7 @@ rule item() -> Item rule rust_doc_comment() -> Option = $(("#" "[" "doc" "=" LITERAL() "]")*)? -rule rust_visibility() -> Option = $("pub" PAREN_GROUP()? / "crate")? +rule rust_visibility() -> Option = $("pub" PAREN_GROUP()?)? rule rust_use() -> TokenStream = v:$("use" rust_path() ( @@ -147,7 +147,7 @@ rule precedence_op() -> PrecedenceOperator { PrecedenceOperator{ span, elements, action } } rule sp() -> Span = ##next_span() -rule KEYWORD() = "pub" / "crate" / "rule" / "use" / "type" +rule KEYWORD() = "pub" / "rule" / "use" / "type" rule IDENT() -> Ident = !KEYWORD() i:##ident() {i} rule LITERAL() -> Literal = ##literal() rule PAREN_GROUP() -> Group = ##group(Delimiter::Parenthesis)