aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--appveyor.yml2
-rw-r--r--bors.toml1
-rw-r--r--src/parser/event_parser/grammar/items.rs9
-rw-r--r--src/parser/event_parser/grammar/mod.rs2
-rw-r--r--tests/data/parser/err/0007_stray_curly_in_file.rs9
-rw-r--r--tests/data/parser/err/0007_stray_curly_in_file.txt28
6 files changed, 46 insertions, 5 deletions
diff --git a/appveyor.yml b/appveyor.yml
index cd7d1c2da..a6ba3b0e1 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,7 +1,7 @@
1os: Visual Studio 2015 1os: Visual Studio 2015
2 2
3install: 3install:
4 - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe 4 - curl https://win.rustup.rs/ --output rustup-init.exe
5 - rustup-init -yv --default-toolchain stable --default-host x86_64-pc-windows-msvc 5 - rustup-init -yv --default-toolchain stable --default-host x86_64-pc-windows-msvc
6 - set PATH=%PATH%;%USERPROFILE%\.cargo\bin 6 - set PATH=%PATH%;%USERPROFILE%\.cargo\bin
7 - rustc -vV 7 - rustc -vV
diff --git a/bors.toml b/bors.toml
index 4e6e85f45..ee7961784 100644
--- a/bors.toml
+++ b/bors.toml
@@ -2,3 +2,4 @@ status = [
2 "continuous-integration/travis-ci/push", 2 "continuous-integration/travis-ci/push",
3 "continuous-integration/appveyor/branch" 3 "continuous-integration/appveyor/branch"
4] 4]
5delete_merged_branches = true
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs
index e569e5047..0638e3093 100644
--- a/src/parser/event_parser/grammar/items.rs
+++ b/src/parser/event_parser/grammar/items.rs
@@ -1,8 +1,8 @@
1use super::*; 1use super::*;
2 2
3pub(super) fn mod_contents(p: &mut Parser) { 3pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
4 attributes::inner_attributes(p); 4 attributes::inner_attributes(p);
5 while !p.at(EOF) { 5 while !p.at(EOF) && !(stop_on_r_curly && p.at(R_CURLY)) {
6 item(p); 6 item(p);
7 } 7 }
8} 8}
@@ -152,7 +152,10 @@ fn mod_item(p: &mut Parser) {
152 p.bump(); 152 p.bump();
153 153
154 if p.expect(IDENT) && !p.eat(SEMI) { 154 if p.expect(IDENT) && !p.eat(SEMI) {
155 p.curly_block(mod_contents); 155 if p.expect(L_CURLY) {
156 mod_contents(p, true);
157 p.expect(R_CURLY);
158 }
156 } 159 }
157} 160}
158 161
diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs
index 82f8b7f3e..b87f3ca8a 100644
--- a/src/parser/event_parser/grammar/mod.rs
+++ b/src/parser/event_parser/grammar/mod.rs
@@ -11,7 +11,7 @@ mod paths;
11pub(crate) fn file(p: &mut Parser) { 11pub(crate) fn file(p: &mut Parser) {
12 let file = p.start(); 12 let file = p.start();
13 p.eat(SHEBANG); 13 p.eat(SHEBANG);
14 items::mod_contents(p); 14 items::mod_contents(p, false);
15 file.complete(p, FILE); 15 file.complete(p, FILE);
16} 16}
17 17
diff --git a/tests/data/parser/err/0007_stray_curly_in_file.rs b/tests/data/parser/err/0007_stray_curly_in_file.rs
new file mode 100644
index 000000000..dc869fb78
--- /dev/null
+++ b/tests/data/parser/err/0007_stray_curly_in_file.rs
@@ -0,0 +1,9 @@
1}
2
3struct S;
4
5}
6
7fn foo(){}
8
9}
diff --git a/tests/data/parser/err/0007_stray_curly_in_file.txt b/tests/data/parser/err/0007_stray_curly_in_file.txt
new file mode 100644
index 000000000..04bf17bc7
--- /dev/null
+++ b/tests/data/parser/err/0007_stray_curly_in_file.txt
@@ -0,0 +1,28 @@
1FILE@[0; 31)
2 ERROR@[0; 3)
3 err: `expected item`
4 R_CURLY@[0; 1)
5 WHITESPACE@[1; 3)
6 STRUCT_ITEM@[3; 14)
7 STRUCT_KW@[3; 9)
8 WHITESPACE@[9; 10)
9 IDENT@[10; 11)
10 SEMI@[11; 12)
11 WHITESPACE@[12; 14)
12 ERROR@[14; 17)
13 err: `expected item`
14 R_CURLY@[14; 15)
15 WHITESPACE@[15; 17)
16 FN_ITEM@[17; 29)
17 FN_KW@[17; 19)
18 WHITESPACE@[19; 20)
19 IDENT@[20; 23)
20 L_PAREN@[23; 24)
21 R_PAREN@[24; 25)
22 L_CURLY@[25; 26)
23 R_CURLY@[26; 27)
24 WHITESPACE@[27; 29)
25 ERROR@[29; 31)
26 err: `expected item`
27 R_CURLY@[29; 30)
28 WHITESPACE@[30; 31)