Skip to content

Confusing error message on syntax error in code in doc comments #6109

Description

@feds01

When enabling format_code_in_doc_comments, the formatter reports that there is a syntax issue in a code block. However the syntax issue source location seems to be confusing/ambigious:

Running rustfmt on the following code snippet produces a confusing error message:

/// Some doc comment with code snippet:
///```
/// '\u{1F}
/// ```
pub struct Code {}

fn main() {}

The error that is produced:

error[E0762]: unterminated character literal
 --> <stdin>:2:5
  |
2 |     '\u{1F}
  |     ^^^^^^^

This is not explicitly a bug, but nonetheless is confusing as it does not indicate the true origin of the issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-commentsArea: commentsE-needs-testCall for participation: the issue is fixed but lacks a regression testgood first issueIssues up for grabs, also good candidates for new rustfmt contributorsonly-with-optionRequires a non-default option value to reproduce

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions