-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Correctly using intra-rustdoc links in no_std crates is difficult #76252
Comments
Depending on the target documentation is built for, libstd might not exist, so these lines cannot be added automatically without breaking a lot of embedded crates. However it seems like a bug that rustdoc does not inject the core library and libcore prelude instead. |
I figured there was something I was missing about this. That seems reasonable, but the problem would still exist when mentioning items only defined in I'm not sure what the best resolution for that would be, but if crates use |
Some thoughts, not for or against this feature yet: #[cfg(doc)]
extern crate std; This will break if another crate depends on your docs: #75855
This is a more general problem than intra-doc links: #73423
Rustdoc should do this already, no? This works fine locally: #![no_std]
//! Link to [`Option`]
Hmm ... that would break any crate that uses |
I think I would recommend passing |
Actually you just made me remember why injecting |
I'll leave this open because I think the discussion is useful, but I don't think rustdoc is going to change it's behavior here. |
I wasn't aware dependencies are built without
I'm not sure I understand, but I agree it's not a great idea.
Right, I guess this would almost require rustdoc to know how to map each item to its documentation link, which seems error-prone.
My specific problem is that I am using an This use case might just be too hard to support. |
Hmm, that seems like something we could change without too much trouble. cc @rust-lang/rustdoc , what do you think about setting
There could be items that are only documented on certain platforms, e.g. winapi is an empty crate on Linux. So if rustdoc overrides the target the documentation would be wrong.
In this particular case, if you had |
I see what you mean now. I actually meant that rustdoc could only use that default when resolving
I should have given a better example. The crate-level documentation references |
I feel like this breaks metadata-only dep doc builds |
You mean like when documenting with |
I'm going to close this because I don't think it's actionable; setting |
AFAICT, if your crate has this line:
#![cfg_attr(not(feature = "std"), no_std)]
and you use a intra-rustdoc link for any
std
item, these lines must be added to build documentation with--no-default-features
:Then, to use items from the prelude in documentation, you'll also want:
However, this defeats the purpose of the prelude being imported automatically. Would it be possible for rustdoc to add these lines even when building with
#![no_std]
?This should also help solve #73423, because the
std
crate would always be in scope.The text was updated successfully, but these errors were encountered: