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

extern crate fails doc tests #2716

Closed
Osspial opened this issue May 18, 2016 · 3 comments
Closed

extern crate fails doc tests #2716

Osspial opened this issue May 18, 2016 · 3 comments

Comments

@Osspial
Copy link

Osspial commented May 18, 2016

If a doc test attempts to import any types declared in it's own crate, including the phrase extern crate anywhere in the code will cause the test to not compile, throwing a "unresolved import" error at the attempted import. For example, if we have struct Foo in crate bar, with the crate baz declared under dev_dependencies, these tests will all fail to compile

/// ```
/// extern crate baz;
/// use bar::Foo;
/// ```
pub struct Foo{}
/// ```
/// // The phrase "extern crate" breaks this!
/// use bar::Foo;
/// ```
pub struct Foo{}
/// ```
/// use bar::Foo;
/// let string = "extern crate";
/// ```
pub struct Foo{}

The following error log is given by cargo test:

running 1 test
test Foo_0 ... FAILED

failures:

---- Foo_0 stdout ----
        <anon>:2:9: 2:12 error: unresolved import `bar::Foo`. Maybe a missing `extern crate bar`? [E0432]
<anon>:2     use bar::Foo;
                 ^~~
error: aborting due to previous error(s)
thread 'Foo_0' panicked at 'Box<Any>', ../src/librustc\session/mod.rs:153
stack backtrace:
   0:         0x61cc34dc - strncmp
   1:         0x61cc2b5c - strncmp
   2:         0x61c84d6f - strncmp
   3:         0x67f193ba - strncmp
   4:         0x67f96c9b - strncmp
   5:         0x6ca6943d - strncmp
   6:         0x6ca6e301 - strncmp
   7:         0x661e3803 - strncmp
   8:         0x61caf9ba - strncmp
   9:         0x661e3bba - strncmp
  10:         0x61cc1209 - strncmp
  11:     0x7fff457f8101 - strncmp


failures:
    Foo_0

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
@alexcrichton
Copy link
Member

Thanks for the report! I think this is actually an upstream rustdoc bug, could you open an issue there instead?

@Osspial
Copy link
Author

Osspial commented May 19, 2016

Sure. It's re-submitted here.

@alexcrichton
Copy link
Member

Thanks!

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

2 participants