-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Rustdoc: strange issues with no_std
#38129
Comments
So, https://doc.rust-lang.org/stable/book/documentation.html#documentation-as-tests
So I would expect that this error wouldn't happen. What's truly strange is that trying this out myself, I get the right kind of error:
|
These errors are fine, since we're creating a |
I created an example project for this issue at phil-opp/issue-38129. When you run |
The heuristic for whether to automatically insert |
And it looks like the book
is lying: it only leaves attributes of the form |
PR submitted. |
rustdoc: fix doctests with non-feature crate attrs Fixes #38129. The book says that any top-level crate attributes at the beginning of a doctest are moved outside the generated `fn main`, but it was only checking for `#![feature`, not `#![`. These attributes previously caused warnings but were then ignored, so in theory this could change the behavior of doctests in the wild.
rustdoc: fix doctests with non-feature crate attrs Fixes #38129. The book says that any top-level crate attributes at the beginning of a doctest are moved outside the generated `fn main`, but it was only checking for `#![feature`, not `#![`. These attributes previously caused warnings but were then ignored, so in theory this could change the behavior of doctests in the wild.
So what is the workaround if I get this error? |
The following doc test fails:
with the error
So rustdoc doesn't recognize the
no_std
attribute.However, when I add the
extern crate
definition manually, it works:It also works for imports from core:
The strange thing is that it also works if I add a comment containing
extern crate
:(With "it works" I mean that the
no_std
attribute is recognized).Edit: I added an example project in at phil-opp/issue-38129 (see the comment below).
The text was updated successfully, but these errors were encountered: