Correctly handle comments in attributes in doctests source code by GuillaumeGomez · Pull Request #134260 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation14 Commits4 Checks6 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

GuillaumeGomez

Fixes #134221.

The problem was that attributes are "inlined" (backlines are stripped), then when there is an inline comment inside it, the attribute is never considered valid (since unclosed). Fix was to simply put back backlines in case it's a multiline attribute.

r? @notriddle

@GuillaumeGomez

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-rustdoc

Relevant to the rustdoc team, which will review and decide on the PR/issue.

labels

Dec 13, 2024

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez

Forgot to set only one test thread to prevent having fuzzy sorting...

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez

And to replace stdout for time too...

@rust-log-analyzer

This comment has been minimized.

@cyrgani

Does this also fix that

//! rust //! #![ //!

is incorrectly treated as a sucessful test?

@GuillaumeGomez

@GuillaumeGomez

@GuillaumeGomez

@GuillaumeGomez

notriddle

Comment on lines 540 to 541

} else if mod_attr_pending.ends_with('\\') {
mod_attr_pending.push('n');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, these lines aren't really needed any more. They would have turned

into

But that only works with double-quoted strings, not raw strings, and is unnecessary now that newlines are preserved here.

} else if mod_attr_pending.ends_with('\\') {
mod_attr_pending.push('n');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a test just in case.

@GuillaumeGomez

@GuillaumeGomez

Removed the backline handling and also added a regression test for it.

@notriddle

@bors

📌 Commit c367cc3 has been approved by notriddle

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Dec 16, 2024

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request

Dec 16, 2024

@GuillaumeGomez

…triddle

Correctly handle comments in attributes in doctests source code

Fixes rust-lang#134221.

The problem was that attributes are "inlined" (backlines are stripped), then when there is an inline comment inside it, the attribute is never considered valid (since unclosed). Fix was to simply put back backlines in case it's a multiline attribute.

r? @notriddle

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request

Dec 16, 2024

@GuillaumeGomez

…triddle

Correctly handle comments in attributes in doctests source code

Fixes rust-lang#134221.

The problem was that attributes are "inlined" (backlines are stripped), then when there is an inline comment inside it, the attribute is never considered valid (since unclosed). Fix was to simply put back backlines in case it's a multiline attribute.

r? @notriddle

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request

Dec 16, 2024

@GuillaumeGomez

…triddle

Correctly handle comments in attributes in doctests source code

Fixes rust-lang#134221.

The problem was that attributes are "inlined" (backlines are stripped), then when there is an inline comment inside it, the attribute is never considered valid (since unclosed). Fix was to simply put back backlines in case it's a multiline attribute.

r? @notriddle

bors added a commit to rust-lang-ci/rust that referenced this pull request

Dec 16, 2024

@bors

…llaumeGomez

Rollup of 9 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request

Dec 16, 2024

@bors

…iaskrgr

Rollup of 9 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Dec 16, 2024

@rust-timer

Rollup merge of rust-lang#134260 - GuillaumeGomez:doctest-attrs, r=notriddle

Correctly handle comments in attributes in doctests source code

Fixes rust-lang#134221.

The problem was that attributes are "inlined" (backlines are stripped), then when there is an inline comment inside it, the attribute is never considered valid (since unclosed). Fix was to simply put back backlines in case it's a multiline attribute.

r? @notriddle

@GuillaumeGomez

Nominating it for beta backporting.

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jan 3, 2025

@bors

[beta] backports

r? cuviper

Labels

beta-accepted

Accepted for backporting to the compiler in the beta channel.

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-rustdoc

Relevant to the rustdoc team, which will review and decide on the PR/issue.