[rust-dev] Issue running documented functions from doc code w/ rustdoc

Jeffery Olson olson.jeffery at gmail.com
Wed Jul 9 06:37:18 PDT 2014


Consider the following docs:


/// Foo
///
/// ```rust
/// under_test();
/// ```
pub fn under_test() {
}

doing `rustdoc main.rs --test` produces:

jeff at jeff-mbp:~/src/rust-intro-presentation/Jun2014$ rustdoc main.rs --test

running 1 test
test foo::under_test_0 ... FAILED

failures:

---- foo::under_test_0 stdout ----
        <anon>:5:5: 5:15 error: unresolved name `under_test`.
        <anon>:5     under_test();
                     ^~~~~~~~~~
        error: aborting due to previous error
        task 'foo::under_test_0' failed at 'Box<Any>',
/home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/
diagnostic.rs:128



failures:
    foo::under_test_0

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


Why is this? I've also tried different combinations of module imports to
get this to work.. the only place this feature is used, extensively, is in
libstd and it appears that maybe this is sidestepped because libstd is
always linked by default? The manual doesn't really cover this in-depth,
either.

Any help would be appreciated.

Thanks,
Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140709/829e3e23/attachment.html>


More information about the Rust-dev mailing list