Unnamed repository; edit this file 'description' to name the repository.
internal: more local parsing tests
5 files changed, 34 insertions, 2 deletions
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index c3ccf6d126..0c35049da3 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs @@ -240,8 +240,6 @@ pub(super) fn opt_item(p: &mut Parser, m: Marker) -> Result<(), Marker> { fn opt_item_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { let la = p.nth(1); match p.current() { - // test extern_crate - // extern crate foo; T![extern] if la == T![crate] => extern_crate(p, m), T![use] => use_item::use_(p, m), T![mod] => mod_item(p, m), @@ -288,11 +286,15 @@ fn opt_item_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { Ok(()) } +// test extern_crate +// extern crate foo; fn extern_crate(p: &mut Parser, m: Marker) { p.bump(T![extern]); p.bump(T![crate]); if p.at(T![self]) { + // test extern_crate_self + // extern crate self; let m = p.start(); p.bump(T![self]); m.complete(p, NAME_REF); @@ -300,6 +302,8 @@ fn extern_crate(p: &mut Parser, m: Marker) { name_ref(p); } + // test extern_crate_rename + // extern crate foo as bar; opt_rename(p); p.expect(T![;]); m.complete(p, EXTERN_CRATE); diff --git a/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_rename.rast b/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_rename.rast new file mode 100644 index 0000000000..87516e9fc4 --- /dev/null +++ b/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_rename.rast @@ -0,0 +1,16 @@ + [email protected] "extern" + [email protected] " " + [email protected] "crate" + [email protected] " " + [email protected] "foo" + [email protected] " " + [email protected] "as" + [email protected] " " + [email protected] "bar" + [email protected] ";" + [email protected] "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_rename.rs b/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_rename.rs new file mode 100644 index 0000000000..fc76e17dda --- /dev/null +++ b/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_rename.rs @@ -0,0 +1 @@ +extern crate foo as bar; diff --git a/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_self.rast b/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_self.rast new file mode 100644 index 0000000000..26b4c0f195 --- /dev/null +++ b/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_self.rast @@ -0,0 +1,10 @@ + [email protected] "extern" + [email protected] " " + [email protected] "crate" + [email protected] " " + [email protected] "self" + [email protected] ";" + [email protected] "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_self.rs b/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_self.rs new file mode 100644 index 0000000000..c969ed1093 --- /dev/null +++ b/crates/syntax/test_data/parser/inline/ok/0168_extern_crate_self.rs @@ -0,0 +1 @@ +extern crate self; |