Skip to content

Commit 19c434a

Browse files
authored
Unrolled build for rust-lang#117932
Rollup merge of rust-lang#117932 - GuillaumeGomez:update-rustdoc-book, r=notriddle Correct rustdoc section where we talk about rustdoc emitting errors on invalid code As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/stop.20accepting.20broken.20code/near/401760318). r? `@notriddle`
2 parents 20f23ab + 38c557c commit 19c434a

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

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

+2-25
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,10 @@ they will both appear in documentation.
3838
Rustdoc does not have a magic way to compile documentation 'as-if' you'd run it once for each
3939
platform (such a magic wand has been called the ['holy grail of rustdoc'][#1998]). Instead,
4040
it sees *all* of your code at once, the same way the Rust compiler would if you passed it
41-
`--cfg doc`. However, Rustdoc has a trick up its sleeve to handle platform-specific code if it
42-
*does* receive it.
43-
44-
To document your crate, Rustdoc only needs to know the public signature of your functions.
45-
In particular, it doesn't have to know how any of your functions are implemented, so it ignores
46-
all type errors and name resolution errors with function bodies. Note that this does *not*
47-
work for anything outside a function body: since Rustdoc documents your types, it has to
48-
know what those types are! For example, this code will work regardless of the platform:
49-
50-
```rust,ignore (platform-specific,rustdoc-specific-behavior)
51-
pub fn f() {
52-
use std::os::windows::ffi::OsStrExt;
53-
}
54-
```
55-
56-
but this will not, because the unknown type is part of the function signature:
57-
58-
```rust,ignore (platform-specific,rustdoc-specific-behavior)
59-
pub fn f() -> std::os::windows::ffi::EncodeWide<'static> {
60-
unimplemented!()
61-
}
62-
```
63-
64-
For a more realistic example of code this allows, see [the rustdoc test suite][realistic-async].
41+
`--cfg doc`. The main difference is that rustdoc doesn't run all the compiler passes, meaning
42+
that some invalid code won't emit an error.
6543

6644
[#1998]: https://github.com/rust-lang/rust/issues/1998
67-
[realistic-async]: https://github.com/rust-lang/rust/blob/b146000e910ccd60bdcde89363cb6aa14ecc0d95/src/test/rustdoc-ui/error-in-impl-trait/realistic-async.rs
6845

6946
## Add aliases for an item in documentation search
7047

0 commit comments

Comments
 (0)