Open
Description
Adding #[macro_export]
to a macro stops it from working in documentation tests. Here's a few examples:
/// Test macro
///
/// #Examples
/// ```
/// test_macro!(TestStructure);
/// ```
#[macro_export]
macro_rules! test_macro {
($expression:ident) => (struct $expression);
}
#[macro_export]
/// Test macro
///
/// #Examples
/// ```
/// test_macro!(TestStructure);
/// ```
macro_rules! test_macro {
($expression:ident) => (struct $expression);
}
They both will yield output similar to this (using cargo):
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
Doc-tests macro_doc
running 1 test
test test_macro!_0 ... FAILED
failures:
---- test_macro!_0 stdout ----
<anon>:2:5: 2:15 error: macro undefined: 'test_macro!'
<anon>:2 test_macro!(TestStructure);
^~~~~~~~~~
error: aborting due to previous error
failures:
test_macro!_0
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
thread '<unnamed>' panicked at 'Some tests failed', ../src/libtest/lib.rs:252
Removing the export makes it work fine:
/// Test macro
///
/// #Examples
/// ```
/// test_macro!(TestStructure);
/// ```
macro_rules! test_macro {
($expression:ident) => (struct $expression);
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status