Closed
Description
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 when there's no reason for them not to:
/// ```
/// 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
Rust version:
rustc 1.8.0 (db2939409 2016-04-11)
binary: rustc
commit-hash: db2939409db26ab4904372c82492cd3488e4c44e
commit-date: 2016-04-11
host: x86_64-pc-windows-gnu
release: 1.8.0