Skip to content

Commit 31bc385

Browse files
committed
rustdoc: Document effect of fundamental types
1 parent ead49f0 commit 31bc385

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/doc/rustdoc/src/unstable-features.md

+29
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,35 @@ To do so, the `#[doc(keyword = "...")]` attribute is used. Example:
197197
mod empty_mod {}
198198
```
199199

200+
## Effects of other nightly features
201+
202+
These nightly-only features are not primarily related to Rustdoc,
203+
but have convenient effects on the documentation produced.
204+
205+
### `fundamental` types
206+
207+
Annotating a type with `#[fundamental]` primarily influences coherence rules about generic types,
208+
i.e., they alter whether other crates can provide implementations for that type.
209+
The unstable book [links to further information][unstable-fundamental].
210+
211+
[unstable-fundamental]: https://doc.rust-lang.org/unstable-book/language-features/fundamental.html
212+
213+
For documentation, this has an additional side effect:
214+
If a method is implemented on `F<T>` (or `F<&T>`),
215+
where `F` is a fundamental type,
216+
then the method is not only documented at the page about `F`,
217+
but also on the page about `T`.
218+
In a sense, it makes the type transparent to Rustdoc.
219+
This is especially convenient for types that work as annotated pointers,
220+
such as `Pin<&mut T>`,
221+
as it ensures that methods only implemented through those annotated pointers
222+
can still be found with the type they act on.
223+
224+
If the `fundamental` feature's effect on coherence is not intended,
225+
such a type can be marked as fundamental only for purposes of documentation
226+
by introducing a custom feature and
227+
limiting the use of `fundamental` to when documentation is built.
228+
200229
## Unstable command-line arguments
201230

202231
These features are enabled by passing a command-line flag to Rustdoc, but the flags in question are

0 commit comments

Comments
 (0)