Skip to content

Commit

Permalink
Update compile fail test error messages
Browse files Browse the repository at this point in the history
Tohe update to syn 2.x introduced some minor changes in
compilation error messages, most notably to #[construct_with]
which required adding a secondary error to provide the same
context-specific error message as before.
  • Loading branch information
james-jra committed Jul 14, 2023
1 parent 324c569 commit b46f7f3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
14 changes: 10 additions & 4 deletions pnet_macros/tests/compile-fail/construct-with-errors.stderr
@@ -1,11 +1,17 @@
error: #[construct_with] must have at least one argument
--> $DIR/construct-with-errors.rs:20:7
--> tests/compile-fail/construct-with-errors.rs:20:7
|
20 | #[construct_with()] //~ ERROR #[construct_with] must have at least one argument
| ^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^

error: #[construct_with] should be of the form #[construct_with(<types>)]
--> $DIR/construct-with-errors.rs:28:22
error: unexpected literal in nested attribute, expected ident
--> tests/compile-fail/construct-with-errors.rs:28:22
|
28 | #[construct_with("test")] //~ ERROR #[construct_with] should be of the form #[construct_with(<types>)]
| ^^^^^^

error: #[construct_with] should be of the form #[construct_with(<primitive types>)]
--> tests/compile-fail/construct-with-errors.rs:28:7
|
28 | #[construct_with("test")] //~ ERROR #[construct_with] should be of the form #[construct_with(<types>)]
| ^^^^^^^^^^^^^^^^^^^^^^
9 changes: 9 additions & 0 deletions pnet_macros/tests/compile-fail/length_expr_parentheses.stderr
Expand Up @@ -5,3 +5,12 @@ error: this file contains an unclosed delimiter
| ^^^^^^^^^ unclosed delimiter
|
= note: this error originates in the derive macro `::pnet_macros::Packet` (in Nightly builds, run with -Z macro-backtrace for more info)

error: proc-macro derive panicked
--> tests/compile-fail/length_expr_parentheses.rs:15:1
|
15 | #[packet]
| ^^^^^^^^^
|
= help: message: compiler/fallback mismatch
= note: this error originates in the attribute macro `packet` (in Nightly builds, run with -Z macro-backtrace for more info)
4 changes: 2 additions & 2 deletions pnet_macros/tests/compile-fail/variable_length_fields.stderr
@@ -1,5 +1,5 @@
error: variable length field must have #[length = ""] or #[length_fn = ""] attribute
--> $DIR/variable_length_fields.rs:16:17
--> tests/compile-fail/variable_length_fields.rs:16:17
|
16 | var_length: Vec<u8>, //~ ERROR: variable length field must have #[length = ""] or #[length_fn = ""] attribute
| ^^^
| ^^^^^^^

0 comments on commit b46f7f3

Please sign in to comment.