proc-macro2 icon indicating copy to clipboard operation
proc-macro2 copied to clipboard

Allow for lexing of non-doc comments

Open Qix- opened this issue 1 year ago • 0 comments

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!

Qix- avatar Aug 23 '24 04:08 Qix-