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

Doc-examples using #[doc] do not have triple backticks stripped before being compiled #78964

Closed
AldaronLau opened this issue Nov 12, 2020 · 7 comments
Labels
A-markdown-parsing Area: Markdown parsing for doc-comments P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@AldaronLau
Copy link
Contributor

Nightly code fails to compile.

Code

I tried this code:

#![cfg_attr(
    feature = "std",
    doc = r#"
        ```rust,no_run
        // Lots of rust code
        ```
    "#
)]

I expected to see this happen: Compiling and working like it does on stable.

Instead, compiler says:

error: unknown start of token: `
   |
24 |     ```
   |     ^
   |
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
   |
24 |     '``
   |     ^

Version it worked on

It most recently worked on: rustc 1.49.0-nightly (ffa2e7a 2020-10-24)

Version with regression

rustc --version --verbose:

rustc 1.49.0-nightly (cf9cf7c92 2020-11-10)
binary: rustc
commit-hash: cf9cf7c923eb01146971429044f216a3ca905e06
commit-date: 2020-11-10
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
@jyn514
Copy link
Member

jyn514 commented Nov 12, 2020

cc @GuillaumeGomez , I think #76154 broke this.

@jyn514 jyn514 added P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 12, 2020
@jyn514 jyn514 changed the title Nightly doc comment backtick looks like single quote Doc-examples using #[doc] do not have triple backticks stripped before being compiled Nov 12, 2020
@jyn514 jyn514 added the A-markdown-parsing Area: Markdown parsing for doc-comments label Nov 12, 2020
@GuillaumeGomez
Copy link
Member

Absolutely!

@Nezeky: Since #76154, we don't allow to "align" comments anymore. You might want to take a look at this blog post.

I'll close this issue and add the label "wont-fix" then.

@juliankrieger
Copy link

@GuillaumeGomez How is one sup[posed to combine #![cfg_attr(not(feature = "xxx"), doc = r#" with no_run when backtick compilation no longer works in that case?

@jyn514
Copy link
Member

jyn514 commented Jul 4, 2022

@juliankrieger the 4 space indent is being interpreted as a code block. Then the rust compiler is run on the block and gives an error about the backticks. The fix is to remove (or just decrease) the indentation.

@juliankrieger
Copy link

I'm afraid I don't quite understand, can you provide a tiny example that works with no_run? Thanks!

@GuillaumeGomez
Copy link
Member

You can't have indented codeblocks with tags.

@jyn514
Copy link
Member

jyn514 commented Jul 7, 2022

@juliankrieger

#![doc = r#"
```rust,no_run
// Lots of rust code
```
"#]

(or use backslashes and \n manually to strip the indentation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-markdown-parsing Area: Markdown parsing for doc-comments P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants