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

[rustdoc] Suggest trailing \ instead of two spaces for hard line break #12163

Open
Marcono1234 opened this issue Jan 17, 2024 · 1 comment · May be fixed by #12876
Open

[rustdoc] Suggest trailing \ instead of two spaces for hard line break #12163

Marcono1234 opened this issue Jan 17, 2024 · 1 comment · May be fixed by #12876
Assignees
Labels
A-lint Area: New lints

Comments

@Marcono1234
Copy link

Marcono1234 commented Jan 17, 2024

What it does

When a rustdoc comment contains two trailing spaces for a Markdown hard line break, the lint should suggest using a trailing backslash (\) instead.

rustdoc uses CommonMark, and it allows using \ for hard line breaks, see the specification.

Advantage

A trailing \ makes the intention for a hard line break clearer than two trailing spaces, which can be difficult to notice in Git diffs, and might be removed accidentally during refactoring.

Drawbacks

  • The choice whether to use two spaces or a \ is subjective
    (this could be solved by adding the lint to clippy::pedantic)
  • If there is not actually a need for a hard line break (e.g. if a > ... follows), then the \ might be shown literally (CommonMark example)

Example

/// First line··
/// Second line
fn foo() {}

(· indicating a space)

Could be written as:

/// First line\
/// Second line
fn foo() {}
@Marcono1234 Marcono1234 added the A-lint Area: New lints label Jan 17, 2024
@Jacherr
Copy link
Contributor

Jacherr commented Jun 1, 2024

This would probably end up being a restriction lint rather than being applied by default, but nevertheless sounds quite useful - I haven't seen the double space method used before, in all honesty.

@rustbot claim

@Jacherr Jacherr linked a pull request Jun 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants