Skip to content

empty # in doc-test causes failure #23106

Closed
@Byron

Description

@Byron

When using the following as module level or item level doc test (module level shown in example) ...

//! ```test_harness,norun
//! # // This is hidden, but the following empty hidden line causes trouble. 
//! # // There is indeed a space after '#'
//! # 
//! # #[test] fn egal() {
//! // visible
//! # }

... the generated markdown looks like this ...
screen shot 2015-03-05 at 13 03 10
... and the output of cargo test like that:

[...]
---- _0 stdout ----
        <anon>:5:1: 5:2 error: expected one of `!` or `[`, found `#`
<anon>:5 #[test] fn egal() {
         ^
thread '_0' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:92
[...]

If the empty hidden line # is removed, it will work such as in the following:

//! ```test_harness,norun
//! # // The hidden empty line was removed, which fixes the issue.
//! # #[test] fn egal() {
//! // visible
//! # }

This is a minor issue, but one that can cause some headaches as people might just not understand what's wrong that easily, at least when looking at the error messages.

Desired behaviour would be to just ignore empty hidden lines entirely.

Meta

✗ cargo --version
cargo 0.0.1-pre-nightly (5773064 2015-02-25) (built 2015-02-25)
✗ rustc --version --verbose
rustc 1.0.0-nightly (4db0b3246 2015-02-25) (built 2015-02-25)
binary: rustc
commit-hash: 4db0b32467535d718d6474de7ae8d1007d900818
commit-date: 2015-02-25
build-date: 2015-02-25
host: x86_64-apple-darwin
release: 1.0.0-nightly

Metadata

Metadata

Assignees

Labels

T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions