diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/pest_generator/src | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/pest_generator/src')
-rw-r--r-- | vendor/pest_generator/src/docs.rs | 10 | ||||
-rw-r--r-- | vendor/pest_generator/src/generator.rs | 14 | ||||
-rw-r--r-- | vendor/pest_generator/src/lib.rs | 5 |
3 files changed, 26 insertions, 3 deletions
diff --git a/vendor/pest_generator/src/docs.rs b/vendor/pest_generator/src/docs.rs index f1ce1881a..ccc82e774 100644 --- a/vendor/pest_generator/src/docs.rs +++ b/vendor/pest_generator/src/docs.rs @@ -119,4 +119,14 @@ mod tests { doc_comment.grammar_doc ); } + + #[test] + fn test_empty_grammar_doc() { + assert!(parser::parse(Rule::grammar_rules, "//!").is_ok()); + assert!(parser::parse(Rule::grammar_rules, "///").is_ok()); + assert!(parser::parse(Rule::grammar_rules, "//").is_ok()); + assert!(parser::parse(Rule::grammar_rules, "/// Line Doc").is_ok()); + assert!(parser::parse(Rule::grammar_rules, "//! Grammar Doc").is_ok()); + assert!(parser::parse(Rule::grammar_rules, "// Comment").is_ok()); + } } diff --git a/vendor/pest_generator/src/generator.rs b/vendor/pest_generator/src/generator.rs index 0dbcaa310..e36e9eb87 100644 --- a/vendor/pest_generator/src/generator.rs +++ b/vendor/pest_generator/src/generator.rs @@ -517,6 +517,13 @@ fn generate_expr(expr: OptimizedExpr) -> TokenStream { state.restore_on_err(|state| #expr) } } + #[cfg(feature = "grammar-extras")] + OptimizedExpr::NodeTag(expr, tag) => { + let expr = generate_expr(*expr); + quote! { + #expr.and_then(|state| state.tag_node(alloc::borrow::Cow::Borrowed(#tag))) + } + } } } @@ -649,6 +656,13 @@ fn generate_expr_atomic(expr: OptimizedExpr) -> TokenStream { state.restore_on_err(|state| #expr) } } + #[cfg(feature = "grammar-extras")] + OptimizedExpr::NodeTag(expr, tag) => { + let expr = generate_expr_atomic(*expr); + quote! { + #expr.and_then(|state| state.tag_node(alloc::borrow::Cow::Borrowed(#tag))) + } + } } } diff --git a/vendor/pest_generator/src/lib.rs b/vendor/pest_generator/src/lib.rs index 7aed1936f..98c726525 100644 --- a/vendor/pest_generator/src/lib.rs +++ b/vendor/pest_generator/src/lib.rs @@ -81,9 +81,8 @@ pub fn derive_parser(input: TokenStream, include_grammar: bool) -> TokenStream { }; data.push_str(&_data); - match _path { - Some(path) => paths.push(path), - None => (), + if let Some(path) = _path { + paths.push(path); } } |