From b1491eacfc2f2ff05ff2a1d3b557c30e15c5f81f Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 2 Sep 2020 00:22:47 +0300 Subject: lexer: Tiny improvement to shebang detection Lexer now discerns between regular comments and doc comments, so use that. The change only affects the choice of reported errors. --- src/test/ui/parser/shebang/shebang-doc-comment.rs | 5 +---- src/test/ui/parser/shebang/shebang-doc-comment.stderr | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/test/ui/parser/shebang/shebang-doc-comment.rs b/src/test/ui/parser/shebang/shebang-doc-comment.rs index 7dbb9eebc75..72866753e0e 100644 --- a/src/test/ui/parser/shebang/shebang-doc-comment.rs +++ b/src/test/ui/parser/shebang/shebang-doc-comment.rs @@ -1,6 +1,3 @@ #!///bin/bash [allow(unused_variables)] -//~^^ ERROR expected `[`, found doc comment - -// Doc comment is misinterpreted as a whitespace (regular comment) during shebang detection. -// Even if it wasn't, it would still result in an error, just a different one. +//~^ ERROR expected item, found `[` diff --git a/src/test/ui/parser/shebang/shebang-doc-comment.stderr b/src/test/ui/parser/shebang/shebang-doc-comment.stderr index f524f556837..2227d45ec5a 100644 --- a/src/test/ui/parser/shebang/shebang-doc-comment.stderr +++ b/src/test/ui/parser/shebang/shebang-doc-comment.stderr @@ -1,8 +1,8 @@ -error: expected `[`, found doc comment `///bin/bash` - --> $DIR/shebang-doc-comment.rs:1:3 +error: expected item, found `[` + --> $DIR/shebang-doc-comment.rs:2:1 | -LL | #!///bin/bash - | ^^^^^^^^^^^ expected `[` +LL | [allow(unused_variables)] + | ^ expected item error: aborting due to previous error -- cgit 1.4.1-3-g733a5