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

5978 Trailing whitespaces are stripped in raw string literals in doc tests #5999

Conversation

IVIURRAY
Copy link
Contributor

Fixes issue: #5978

WIP: Have created the test for this feature just need to implement the code.

@ytmimi
Copy link
Contributor

ytmimi commented Dec 29, 2023

Thanks for picking this up! based on my up front investigation I suspect this will be tricky one to solve (but I could be wrong). If you're looking for a good first issues to work on I might be able to find a few from the backlog.

@IVIURRAY
Copy link
Contributor Author

IVIURRAY commented Dec 29, 2023

Ok, I'm a little stuck on this one. Wondering if I can get some help. I've read over the documentation provided on the github page and followed the advice on #5978 (comment) but still struggling to understand where to make this change.

rustfmt/src/comment.rs

Lines 376 to 383 in 2174e60

rewrite_comment_inner(
first_group,
block_style,
style,
shape,
config,
is_doc_comment || style.is_doc_comment(),
)?

I can see on the above code block I'm getting the following output. Now, I what I don't understand is if I should have the r#"" block as its own Span to be processed or if I should process it as part of this snippet.

/// String literal test
/// ```rust
/// let expected = "\nfoo \n";
/// assert_eq!(expected, r#"
/// foo
/// "#);
/// ```

I'm thinking if I was to process this in its own snippet then I would probably mark some sort of "is inside raw code block" variable and not touch the following lines until I see the "# end.

Would apprechiate some help on this one :)

@IVIURRAY
Copy link
Contributor Author

@ytmimi - ha you must've been reading my mind. I just commeted for help as you replied.

I did look over the "good first issue" tags but nothing took my fancy or I just didn't understand that is why I opted for a more recent issue. I am looking to get more involved in Rust so any issues you fire my way I will happily try to take a look (maybe with some guidence).

@ytmimi
Copy link
Contributor

ytmimi commented Dec 29, 2023

@IVIURRAY great to hear that you want to get more involved! The team greatly appreciates the help 🙏🏼! For now, take a look at #5801. If you need help feel free to reach out on Rust’s Zulip in the t-rustfmt stream.

@IVIURRAY IVIURRAY closed this Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants