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

format_code_in_doc_comments not applied when containing macros which takes an abstract stream of tokens #6454

Open
sorairolake opened this issue Jan 25, 2025 · 0 comments
Labels
a-comments only-with-option requires a non-default option value to reproduce

Comments

@sorairolake
Copy link

The following doctest has no space after the comma on line 4:

/// ```
/// use time::{macros::datetime, OffsetDateTime};
///
/// assert_eq!(datetime!(1970-01-01 00:00 UTC),OffsetDateTime::UNIX_EPOCH);
/// ```

I ran cargo fmt with the format_code_in_doc_comments option set to true to format this doctest, but this doctest was not formatted.

The expected result is:

/// ```
/// use time::{macros::datetime, OffsetDateTime};
///
-/// assert_eq!(datetime!(1970-01-01 00:00 UTC),OffsetDateTime::UNIX_EPOCH);
+/// assert_eq!(datetime!(1970-01-01 00:00 UTC), OffsetDateTime::UNIX_EPOCH);
/// ```

Note that Rust code other than doctests, such as unit tests, was formatted as expected.

#[cfg(test)]
mod tests {
    use time::{macros::datetime, OffsetDateTime};

    use super::*;

    #[test]
    fn it_works() {
        assert_eq!(datetime!(1970-01-01 00:00 UTC),OffsetDateTime::UNIX_EPOCH);
    }
}

The above unit test was formatted as expected as follows:

#[cfg(test)]
mod tests {
    use time::{macros::datetime, OffsetDateTime};

    use super::*;

    #[test]
    fn it_works() {
        assert_eq!(datetime!(1970-01-01 00:00 UTC), OffsetDateTime::UNIX_EPOCH);
    }
}
@ytmimi ytmimi added a-comments only-with-option requires a non-default option value to reproduce labels Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments only-with-option requires a non-default option value to reproduce
Projects
None yet
Development

No branches or pull requests

2 participants