Skip to content

Add new unescaped_pipe_in_table_cell rustdoc lint#159583

Open
GuillaumeGomez wants to merge 3 commits into
rust-lang:mainfrom
GuillaumeGomez:unescaped_pipe_in_table_cell
Open

Add new unescaped_pipe_in_table_cell rustdoc lint#159583
GuillaumeGomez wants to merge 3 commits into
rust-lang:mainfrom
GuillaumeGomez:unescaped_pipe_in_table_cell

Conversation

@GuillaumeGomez

Copy link
Copy Markdown
Member

Fixes #159186.

r? @Urgau

@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 Jul 19, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread tests/rustdoc-ui/lints/unescaped_pipe_in_table_cell.rs
Comment thread src/librustdoc/passes/lint/table_pipe_escape.rs
Comment thread src/librustdoc/passes/lint/table_pipe_escape.rs Outdated
Comment thread src/librustdoc/passes/lint/table_pipe_escape.rs Outdated
Comment thread src/librustdoc/passes/lint/table_pipe_escape.rs Outdated
Comment thread src/librustdoc/passes/lint/table_pipe_escape.rs
Comment thread src/librustdoc/passes/lint/table_pipe_escape.rs
@Urgau Urgau added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 20, 2026
@GuillaumeGomez
GuillaumeGomez force-pushed the unescaped_pipe_in_table_cell branch from 045f5a3 to 6fd9b1b Compare July 21, 2026 12:16
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Applied comments.

@Urgau Urgau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Implementation looks good to me.

View changes since this review

@Urgau Urgau added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 21, 2026
@Urgau

This comment was marked as outdated.

@rust-rfcbot

This comment was marked as resolved.

@Urgau

Urgau commented Jul 21, 2026

Copy link
Copy Markdown
Member

2nd try. Let's do an FCP.

unescaped_pipe_in_table_cell details

unescaped_pipe_in_table_cell

This lint is warn-by-default. It detects unescaped pipes (|) in table rows which
lead to some row cells being ignored. For example:

//! | col1 |
//! | ---- |
//! | `code_with(|arg| arg)` |

Which will give:

error: table row has too many columns
  --> $DIR/unescaped_pipe_in_table_cell.rs:5:18
   |
5  | //! | `code_with(|arg| arg)` |
   |                  ^ help: any content after this column divider is discarded
   |
   = help: to escape `|` characters in tables, add a `\` before them like `\|`
note: the lint level is defined here
  --> $DIR/unescaped_pipe_in_table_cell.rs:1:9
   |
1  | #![deny(rustdoc::unescaped_pipe_in_table_cell)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@rfcbot merge rustdoc-internals

@rust-rfcbot

rust-rfcbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

@Urgau has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jul 21, 2026
@Urgau Urgau added S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 21, 2026
```rust
//! | col1 |
//! | ---- |
//! | `code_with(|arg| arg)` |

@camelid camelid Jul 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wow TIL that this is how GFM works. Very strange design...

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah I was super confused as well.


#[derive(Diagnostic)]
#[diag("table row has too many columns")]
#[help("to escape `|` characters in tables, add a `\\` before them like `\\|`")]

@notriddle notriddle Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
#[help("to escape `|` characters in tables, add a `\\` before them like `\\|`")]
#[help(r"to escape `|` characters in tables, add a `\` before them like `\|`")]

View changes since the review

@notriddle notriddle Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Please add a test case for tables with fewer cells in a row than the head. I suppose it should be silent, but we want to make sure it doesn’t ICE or something.
| one | two |
|-|-|
| a |
| b
  • Please add test cases for tables that don’t have leading and trailing pipes. You’re parsing the table syntax, so you need to test these corner cases.
one | two
-|-
a | b | c
a |

*[View changes since the review](https://triagebot.infra.rust-lang.org/gh-changes-since/rust-lang/rust/159583/cde3f8aee5a30928872e2438e3f18238a3fa306c..6fd9b1bce2dd4cd99e32dc333104810bef776cc0)*

//! | col |
//! | ---- |
//! | code_with | aaaaa
//^ the "aaaaa" part will be ignored.

@notriddle notriddle Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is it ignored? It seems like an example of the thing you’re trying to warn about.

col
code_with

View changes since the review

@notriddle

Copy link
Copy Markdown
Contributor

Minor nits about the implementation, but massive approval for the lint in concept!

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

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown tables can silently discard content containing |

7 participants