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

Add errata print01-ch07-lst2-open-paren #32

Merged
merged 5 commits into from
Jan 21, 2023

Conversation

nmarley
Copy link
Contributor

@nmarley nmarley commented Jan 5, 2023

No description provided.

@jonhoo
Copy link
Owner

jonhoo commented Jan 7, 2023

Good catch! I'd actually like the fix to be the the other way though — we should change the closing paren to a brace }. Macros can be called with either, and this is less like an argument list than a block, so {} feels more appropriate.

@nmarley
Copy link
Contributor Author

nmarley commented Jan 8, 2023

Thanks, I had no idea! I will push a commit to use a brace instead.

@jonhoo
Copy link
Owner

jonhoo commented Jan 8, 2023

I believe the ; is still needed. I think you need one to terminate all function-like macro invocations 🤔

Also, would you mind updating the file name?

@nmarley
Copy link
Contributor Author

nmarley commented Jan 8, 2023

No problem updating the filename.

Regarding the semicolon, I got an error when trying it with a brace + semicolon during my own testing. Would you be able to double-check? If you insist I can remove it.

Here is the error I got:

error: expected item, found `;`
  --> test2.rs:21:53
   |
21 | test_battery! {u8 as u8_tests3, u128 as u128_tests3};
   |                                                     ^ help: remove this semicolon

error: aborting due to previous error

Here is my code if it helps:

https://gist.github.com/nmarley/0831cf27ca12ce7e6b1234af8162e94e

@nmarley
Copy link
Contributor Author

nmarley commented Jan 9, 2023

It seems like println! works with braces both with and without the ;, so I'll just assume there's some magic that I don't yet understand and add the semicolon here.

@jonhoo
Copy link
Owner

jonhoo commented Jan 14, 2023

Huh, no, looks like you're spot on. From the reference, macro invocations with a {} are not ;-terminated:

MacroInvocationSemi :
      SimplePath ! ( TokenTree* ) ;
   | SimplePath ! [ TokenTree* ] ;
   | SimplePath ! { TokenTree* }

This is also supported by rust-lang/rust#34418.

So let's get rid of the ; again then!

This reverts commit 14f12b9.
@nmarley
Copy link
Contributor Author

nmarley commented Jan 20, 2023

Oh nice! Thanks for letting me know where to find this information.

Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jonhoo jonhoo merged commit 093bfc8 into jonhoo:main Jan 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants