Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the diagnostic renderer to avoid printing trailing whitespace #430

Merged
merged 21 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error: encountered unmatched `[` delimiter
--> testdata/lexer/braces/interleaved.proto:2:5
|
|
2 | [
| ^ expected a closing `]`
3 | }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error: encountered unmatched `{` delimiter
--> testdata/lexer/braces/stray-close.proto:1:1
|
|
1 | {
| ^ expected a closing `}`
2 | ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error: encountered unmatched `[` delimiter
--> testdata/lexer/braces/stray-open.proto:2:5
|
|
2 | [
| ^ expected a closing `]`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error: encountered unmatched `(` delimiter
--> testdata/lexer/braces/unclosed.proto:1:1
|
|
1 | (
| ^ expected a closing `)`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error: encountered unmatched `)` delimiter
--> testdata/lexer/braces/unopened.proto:1:1
|
|
1 | )
| ^ expected a closing `(`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error: encountered unmatched `*/` delimiter
--> testdata/lexer/comments/nested.proto:4:1
|
|
4 | */
| ^^ expected a closing `/*`
= note: Protobuf does not support nested block comments
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error: encountered unmatched `/*` delimiter
--> testdata/lexer/comments/unterminated.proto:1:1
|
|
1 | /*
| ^^ expected a closing `*/`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
error: unrecognized token
--> testdata/lexer/idents/non-ascii.proto:1:7
|
|
1 | kitty_🐈<U+200D>⬛
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^

error: non-ASCII identifiers are not allowed
--> testdata/lexer/idents/non-ascii.proto:2:1
|
2 | 黑猫
| ^^^^
|
2 | 黑猫
| ^^^^

error: non-ASCII identifiers are not allowed
--> testdata/lexer/idents/non-ascii.proto:3:1
|
|
3 | काली बिल्ली
| ^^^^
| ^^^^

error: non-ASCII identifiers are not allowed
--> testdata/lexer/idents/non-ascii.proto:3:6
|
|
3 | काली बिल्ली
| ^^^^^
| ^^^^^

error: non-ASCII identifiers are not allowed
--> testdata/lexer/idents/non-ascii.proto:4:1
|
|
4 | 黑猫_suffix
| ^^^^^^^^^^^
| ^^^^^^^^^^^

encountered 5 errors
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
error: unexpected characters in integer literal
--> testdata/lexer/numbers/bad-digit.proto:1:1
|
|
1 | 0f
| ^^
| ^^

error: unexpected characters in integer literal
--> testdata/lexer/numbers/bad-digit.proto:2:1
|
|
2 | 0b02
| ^^^^
| ^^^^

error: unexpected characters in integer literal
--> testdata/lexer/numbers/bad-digit.proto:3:1
|
|
3 | 0o08
| ^^^^
| ^^^^

error: unexpected characters in integer literal
--> testdata/lexer/numbers/bad-digit.proto:4:1
|
|
4 | 08
| ^^
| ^^

error: unexpected characters in integer literal
--> testdata/lexer/numbers/bad-digit.proto:5:1
|
|
5 | 0x0G
| ^^^^
| ^^^^

encountered 5 errors
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
error: unsupported base for integer literal
--> testdata/lexer/numbers/exotic-base.proto:1:1
help: use a hexadecimal literal instead
|
|
1 | - 0b1100101
1 | + 0x65
|
|
= note: Protobuf does not support binary literals

error: unsupported base for integer literal
--> testdata/lexer/numbers/exotic-base.proto:2:1
help: use a hexadecimal literal instead
|
|
2 | - 0B1010101
2 | + 0x55
|
|
= note: Protobuf does not support binary literals

error: unsupported base for integer literal
--> testdata/lexer/numbers/exotic-base.proto:3:1
help: remove the `o`
|
|
3 | - 0o1234567
3 | + 01234567
|
|
= note: octal literals are prefixed with `0`, not `0o`

error: unsupported base for integer literal
--> testdata/lexer/numbers/exotic-base.proto:4:1
help: remove the `o`
|
|
4 | - 0O1234567
4 | + 01234567
|
|
= note: octal literals are prefixed with `0`, not `0o`

error: unexpected characters in floating-point literal
--> testdata/lexer/numbers/exotic-base.proto:6:1
|
|
6 | 0x10203.4
| ^^^^^^^^^
| ^^^^^^^^^

error: unexpected characters in floating-point literal
--> testdata/lexer/numbers/exotic-base.proto:7:1
|
|
7 | 0X12.ffP10
| ^^^^^^^^^^
| ^^^^^^^^^^

encountered 6 errors
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
error: integer literal contains underscores
--> testdata/lexer/numbers/thousands.proto:1:1
help: remove these underscores
|
|
1 | - 1_000_000
1 | + 1000000
|
|
= note: Protobuf does not support Go/Java/Rust-style thousands separators

error: unsupported base for integer literal
--> testdata/lexer/numbers/thousands.proto:2:1
help: use a hexadecimal literal instead
|
|
2 | - 0b1_000_000
2 | + 0x40
|
|
= note: Protobuf does not support binary literals

error: unsupported base for integer literal
--> testdata/lexer/numbers/thousands.proto:3:1
help: remove the `o`
|
|
3 | - 0o1_000_000
3 | + 01_000_000
|
|
= note: octal literals are prefixed with `0`, not `0o`

error: integer literal contains underscores
--> testdata/lexer/numbers/thousands.proto:4:1
help: remove these underscores
|
|
4 | - 0x1_000_000
4 | + 0x1000000
|
|
= note: Protobuf does not support Go/Java/Rust-style thousands separators

error: integer literal contains underscores
--> testdata/lexer/numbers/thousands.proto:5:1
help: remove these underscores
|
|
5 | - 01_000_000
5 | + 01000000
|
|
= note: Protobuf does not support Go/Java/Rust-style thousands separators

error: floating-point literal contains underscores
--> testdata/lexer/numbers/thousands.proto:6:1
help: remove these underscores
|
|
6 | - 1_000_000.00
6 | + 1000000.00
|
|
= note: Protobuf does not support Go/Java/Rust-style thousands separators

encountered 6 errors
36 changes: 18 additions & 18 deletions experimental/parser/testdata/lexer/punct.proto.stderr.txt
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
error: unrecognized token
--> testdata/lexer/punct.proto:2:1
|
|
2 | ! @ # $ % ^ & * + _
| ^
| ^

error: unrecognized token
--> testdata/lexer/punct.proto:2:3
|
|
2 | ! @ # $ % ^ & * + _
| ^
| ^

error: unrecognized token
--> testdata/lexer/punct.proto:2:5
|
|
2 | ! @ # $ % ^ & * + _
| ^
| ^

error: unrecognized token
--> testdata/lexer/punct.proto:2:7
|
|
2 | ! @ # $ % ^ & * + _
| ^
| ^

error: unrecognized token
--> testdata/lexer/punct.proto:2:9
|
|
2 | ! @ # $ % ^ & * + _
| ^
| ^

error: unrecognized token
--> testdata/lexer/punct.proto:2:11
|
|
2 | ! @ # $ % ^ & * + _
| ^
| ^

error: unrecognized token
--> testdata/lexer/punct.proto:2:13
|
|
2 | ! @ # $ % ^ & * + _
| ^
| ^

error: unrecognized token
--> testdata/lexer/punct.proto:2:15
|
|
2 | ! @ # $ % ^ & * + _
| ^
| ^

error: unrecognized token
--> testdata/lexer/punct.proto:2:17
|
|
2 | ! @ # $ % ^ & * + _
| ^
| ^

encountered 9 errors
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
error: unescaped newlines are not permitted in string literals
--> testdata/lexer/strings/bad-contents.proto:1:13
|
|
1 | "this string
| ^ replace this with `\n`

error: unescaped newlines are not permitted in string literals
--> testdata/lexer/strings/bad-contents.proto:3:2
|
|
3 | "
| ^ replace this with `\n`

error: unescaped NUL bytes are not permitted in string literals
--> testdata/lexer/strings/bad-contents.proto:6:30
|
|
6 | "this string contains a nul: <U+0000>"
| ^^^^^^^^ replace this with `\0` or `\x00`

error: unescaped NUL bytes are not permitted in string literals
--> testdata/lexer/strings/bad-contents.proto:7:29
|
|
7 | "this string contains a nul <U+0000> in the middle"
| ^^^^^^^^ replace this with `\0` or `\x00`

error: unescaped NUL bytes are not permitted in string literals
--> testdata/lexer/strings/bad-contents.proto:8:2
|
|
8 | "<U+0000>"
| ^^^^^^^^ replace this with `\0` or `\x00`

warning: non-printable character in string literal
--> testdata/lexer/strings/bad-contents.proto:10:57
|
|
10 | "this string contains some other non-graphic character: <U+0001>"
| ^^^^^^^^ help: consider escaping this with e.g. `\x01` instead

warning: non-printable character in string literal
--> testdata/lexer/strings/bad-contents.proto:11:39
|
|
11 | "this is graphic but non-ASCII space: <U+00A0>"
| ^^^^^^^^ help: consider escaping this with e.g. `\u00a0` instead

Expand Down
Loading
Loading