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

Feature request: carry comments in the middle of function bodies down to LLBC #340

Closed
msprotz opened this issue Aug 29, 2024 · 3 comments
Closed
Assignees

Comments

@msprotz
Copy link
Contributor

msprotz commented Aug 29, 2024

In the following snippet, I would like a way to retrieve the comment in LLBC.

fn foo() -> u32 {
 // Bar
  0
}

Possible thoughts include:

  • looking up the text via span information
  • using a rustdoc comment in the hope that it gets attached to an AST node
  • ...?

Thanks!

@Nadrieril
Copy link
Member

Turns out clippy has a lint that detects // SAFETY comments before unsafe blocks. They do span shenanigans to recover the comments. Code is here for inspiration.

@Nadrieril
Copy link
Member

I made a decent attempt here: #358, which is made mostly pointless by #233.

@Nadrieril
Copy link
Member

Nadrieril commented Sep 13, 2024

Alright, this now works! Comments on each statement are accessible in comments_before.

The heuristic for where to place comments is quite naive however, so please report back if comments end up in surprising places.

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