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

Allow for lexing of non-doc comments #468

Open
Qix- opened this issue Aug 23, 2024 · 1 comment
Open

Allow for lexing of non-doc comments #468

Qix- opened this issue Aug 23, 2024 · 1 comment

Comments

@Qix-
Copy link

Qix- commented Aug 23, 2024

Normally a lexer (rightfully) excludes non-doc comments but I have a particular usecase where having the opt-in ability to lex normal comments would be appreciated.

In a safety-critical project I'd like to write a lint pass whereby all instances of unsafe {} blocks are commented with a // SAFETY comment explaining the use of the unsafe block in order to enforce this documentation. It's a convention in the codebase already but it's something I'd like to make sure is enforceable via CI.

I could fork proc-macro2 to add this of course but I wanted to see if this was something upstream would be interested in having, or at least to see if there was maybe a better way of going about doing this - especially since having the feature enabled would break syn parsing unless it was patched to ignore comment tokens.

Would the better approach just be to allow the "useless doc comment" lint and instead enforce that statements with unsafe blocks have a #[doc] attribute?

Thanks for any info!

@phR0ze
Copy link

phR0ze commented Oct 4, 2024

Definitely an interesting idea in my opinion. I'd love to see proc-macro2 and syn both updated to support regular comments. This would open up some nice use cases with pretty-print as well.

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