Skip to content

Document usage of extern crate declaration in doctests #30137

Closed
@contradictioned

Description

@contradictioned

When a doctest like this is written:

///
/// ```
/// extern crate mylib;
/// use mylib::something;
/// ...
/// ```

running the tests will produce an error like:

unresolved import `mylib::something`. Did you mean `self::mylib`? [E0432]

since the test code is wrapped inside a fn main() for execution.

This is imho not clear in this algorithm description https://doc.rust-lang.org/stable/book/documentation.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions