Skip to content

rustdoc --test should be able to expand exported macros defined in the same crate #16893

Closed
@japaric

Description

@japaric

I have lots of doctests/examples like this one in my library:

#![feature(macro_rules)]

#[macro_export]
/// Construct a `Mat` containing the arguments
macro_rules! mat {
    () => { unimplemented!() };
}

pub struct Mat;

impl Mat {
    /// Constructs a matrix filled with zeros
    ///
    /// # Example
    ///
    /// ```
    /// assert_eq!(Mat::zeros((2, 2)), mat![0, 0; 0, 0])
    /// ```
    pub fn zeros(size: (uint, uint)) -> Mat {
        unimplemented!();
    }
}

But rustdoc is not able to expand the mat! macro, which is defined and exported in the same crate:

$ rustdoc --test lib.rs
running 1 test
test zeros_0 ... FAILED

failures:

---- zeros_0 stdout ----
        <anon>:5:36: 5:39 error: macro undefined: 'mat!'
        <anon>:5     assert_eq!(Mat::zeros((2, 2)), mat![0, 0; 0, 0])
                                                    ^~~
        error: aborting due to previous error
        task 'zeros_0' failed at 'Box<Any>', /var/tmp/paludis/build/dev-lang-rust-scm/work/rust-scm/src/libsyntax/ast_util.rs:784



failures:
    zeros_0

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

task '<unnamed>' failed at 'Some tests failed', /var/tmp/paludis/build/dev-lang-rust-scm/work/rust-scm/src/libtest/lib.rs:242

It'd be great if this worked. (Meanwhile, I'll mark my doctests as ignored)

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions