Skip to content

doc-tests don't work with macros 1.1 #3545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
colin-kiegel opened this issue Jan 15, 2017 · 0 comments · Fixed by #3552
Closed

doc-tests don't work with macros 1.1 #3545

colin-kiegel opened this issue Jan 15, 2017 · 0 comments · Fixed by #3552

Comments

@colin-kiegel
Copy link

It looks like having proc-macro = true in Cargo.toml disables all doc-tests. However unit tests #[test] work fine.

Steps to reproduce

  1. cargo new foo

  2. edit Cargo.toml

# ... the usual
[lib]
proc-macro = true
  1. edit src/lib.rs
//! ```rust
//! fn main() { panic!() } /* <-- this test should fail */
//! ```

#![crate_type = "proc-macro"]
extern crate proc_macro;

#[proc_macro_derive(Foo)]
pub fn derive(_: proc_macro::TokenStream) -> proc_macro::TokenStream {
    unimplemented!()
}
  1. cargo test
running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
bors added a commit that referenced this issue Jan 18, 2017
Allow doc tests to run on proc macro crates

Fixes #3545

Since `--test` works for rustc, doctests should also work. Currently cargo isn't setup to run doctests for proc macro crates, this PR adds them to the list.

Currently rustdoc can run doctests for proc-macro crates, but the `phase_2_configure_and_expand` call` triggers the following warning:

```
the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
```

So perhaps this PR should wait until I've finished creating/testing the PR for rustc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant