Skip to content

rustdoc seems to ignore edition2018 attribute #58875

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
Alexander-N opened this issue Mar 2, 2019 · 2 comments
Closed

rustdoc seems to ignore edition2018 attribute #58875

Alexander-N opened this issue Mar 2, 2019 · 2 comments
Labels
A-doctests Area: Documentation tests, run by rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Alexander-N
Copy link

Running

rustdoc -L target/debug/deps --test test.md

with the following content of test.md

```edition2018
// extern crate clap;
use clap::Arg;
```

gives me

running 1 test
test test.md -  (line 1) ... FAILED

failures:

---- test.md -  (line 1) stdout ----
error[E0432]: unresolved import `clap`
 --> test.md:3:5
  |
4 | use clap::Arg;
  |     ^^^^ use of undeclared type or module `clap`

thread 'test.md -  (line 1)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:351:13
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

The test passes when I uncomment extern crate clap.

This is a problem when code blocks in the documentation should get tested, see amethyst/amethyst#1364 (comment) for an example.

Meta

rustdoc --version --verbose:
rustdoc 1.34.0-nightly (aadbc45 2019-02-23)
binary: rustdoc
commit-hash: aadbc45
commit-date: 2019-02-23
host: x86_64-unknown-linux-gnu
release: 1.34.0-nightly
LLVM version: 8.0

@ehuss
Copy link
Contributor

ehuss commented Mar 2, 2019

I think that is expected. Crates are only added to the extern prelude if the --extern flag is used. Since mdbook doesn't really know about extern crates (rust-lang/mdBook#706), you'll probably need to keep the extern crate lines (or figure out how to pass the correct --extern flags to rustdoc).

@jonas-schievink jonas-schievink added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-doctests Area: Documentation tests, run by rustdoc labels Mar 2, 2019
@Alexander-N
Copy link
Author

Ok, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants