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

Parsing ItemMod fails #393

Closed
Bert-Proesmans opened this issue Apr 4, 2018 · 2 comments
Closed

Parsing ItemMod fails #393

Bert-Proesmans opened this issue Apr 4, 2018 · 2 comments

Comments

@Bert-Proesmans
Copy link

I built a reproduction here: https://github.com/Bert-Proesmans/syn-issue

The reproduction consists of an attribute macro which simply parses and tokenizes it's input. The attribute must be attached to modules. Each 'test-suite' is guarded by a feature flag.
The reproduction demonstrates the following:

  • In test cases 1 (one_two) and 4 (four_two) parsing an ItemMod fails because inner sugared documentation is present before another inner attribute. The compiler allows inner sugared docs to be placed before any other inner attribute, so this is an issue.
    The workaround is to place the inner sugar documentation after all inner attributes.

  • Inner sugar docs lose their attachment. This can be observed in test cases 1 (one_one), 4 (four_one).
    Also after fixing test case one_two, four_two by moving the inner sugar doc below other inner attributes.
    After parsing the module and tokenizing again the sugar doc is wrongly converted into a doc-attribute. This attribute is missing it's bang-token so it becomes attached to the next syntax item.
    See below
    afbeelding

  • As mentioned in issue Remove Attribute::is_sugared_doc #389, documentation that is parsed by syn contains the triple slashes '/' before it's content. The image above also demonstrates this.

@dtolnay
Copy link
Owner

dtolnay commented Apr 4, 2018

Thanks for the helpful reproduction! Looks like there are a lot of things wrong here. I filed dtolnay/proc-macro2#73 and rust-lang/rust#49655 and rust-lang/rust#49656 to begin with, and let's see whether anything is still wrong after fixing those.

@dtolnay
Copy link
Owner

dtolnay commented Apr 6, 2018

I believe all of these bugs have been fixed as of rustc 1.27.0-nightly (48fa6f963 2018-04-05) and proc-macro2 0.3.5. Let me know if anything still seems incorrect!

@dtolnay dtolnay closed this as completed Apr 6, 2018
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

No branches or pull requests

2 participants