Skip to content

empty # in doc-test causes failure #1380

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

Closed
Byron opened this issue Mar 5, 2015 · 3 comments
Closed

empty # in doc-test causes failure #1380

Byron opened this issue Mar 5, 2015 · 3 comments

Comments

@Byron
Copy link
Member

Byron commented Mar 5, 2015

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
//! # 
//! # #[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
@steveklabnik
Copy link
Member

This is a rustdoc issue, not a cargo issue

@alexcrichton
Copy link
Member

Yes right now rustdoc will only strip lines that start with "# " (note the space after the #) and it looks like you may not have a space after the #-character. Regardless though @steveklabnik is right, could you open this on the rust-lang/rust repo instead of this if you'd like to continue pursuing it? Thanks!

@Byron
Copy link
Member Author

Byron commented Mar 6, 2015

Thanks for the info, I have just opened #23106.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants