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

Comments mess with rustdoc's auto-test insertion behavior #51685

Closed
steveklabnik opened this issue Jun 21, 2018 · 1 comment
Closed

Comments mess with rustdoc's auto-test insertion behavior #51685

steveklabnik opened this issue Jun 21, 2018 · 1 comment
Labels
A-doctests Area: Documentation tests, run by rustdoc C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@steveklabnik
Copy link
Member

Simplest to see in action:

C:\Users\steve\tmp> cat foo.rs
/// ```
/// #![feature(box_syntax)]
///
/// let five = box 5;
/// ```
///
pub fn passes() {}

/// ```
/// // a comment
/// #![feature(box_syntax)]
///
/// let five = box 5;
/// ```
///
pub fn fails() {}
C:\Users\steve\tmp> rustdoc --test foo.rs

running 2 tests
test foo.rs - fails (line 9) ... FAILED
test foo.rs - passes (line 1) ... ok

failures:

---- foo.rs - fails (line 9) stdout ----
error[E0658]: box expression syntax is experimental; you can call `Box::new` instead. (see issue #49733)
 --> foo.rs:13:12
  |
6 | let five = box 5;
  |            ^^^^^
  |
  = help: add #![feature(box_syntax)] to the crate attributes to enable

thread 'foo.rs - fails (line 9)' panicked at 'couldn't compile the test', librustdoc\test.rs:325:17
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    foo.rs - fails (line 9)

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

including the comment means that everything gets wrapped in a main, which means the feature flag is wrapped in a main, and therefore doesn't turn on. this is very confusing.

@steveklabnik steveklabnik added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jun 21, 2018
@Centril Centril added the C-bug Category: This is a bug. label Jun 21, 2018
@jyn514 jyn514 added the A-doctests Area: Documentation tests, run by rustdoc label Aug 27, 2020
@carols10cents
Copy link
Member

I believe this was fixed by #54861; I can no longer reproduce this.

(I was looking into how rustdoc's fn main wrapping works for book reasons and found this issue and that PR :))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc C-bug Category: This is a bug. 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