Skip to content

Commit 6d05c43

Browse files
committed
Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease
rustdoc: show crate name beside smaller logo *Blocked on rust-lang/cargo#12800 ## Summary In this PR, the crate name and version are always shown in the sidebar, even in subpages, and the lateral navigation is always shown in the sidebar, even in modules. Clicking the crate name does the same thing clicking the logo always did: take you to the crate root (the crate's home page, at least within Rustdoc). The Rust logo is also no longer shown by default for non-Rust docs. ### Screenshots <details><summary>Before</summary> | | Macro | Module | |--|-------|--------| | In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/d5db0a46-2bb6-44a2-a3aa-2d915ecb8595) |![image](https://github.com/rust-lang/rust/assets/1593513/61f8c1ee-c298-4e2c-b791-18ecb79ab83b) | In module[^1] | ![image](https://github.com/rust-lang/rust/assets/1593513/73abca59-0b69-4650-a1e2-7278ca34795c) | ![image](https://github.com/rust-lang/rust/assets/1593513/0baf02c2-2ec7-4674-80e5-a6a74a973376) [^1]: This PR also includes a bug fix for derive macros not showing up in the lateral navigation part of the sidebar </details> #### Whole sidebar screenshots | | Macro | Module | |--|-------|--------| | In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/75d1bd07-41f7-4f11-ba24-fd5476e0586a) | ![image](https://github.com/rust-lang/rust/assets/1593513/52960259-2b65-4131-b380-01826f0a0eb7) | In module | ![image](https://github.com/rust-lang/rust/assets/1593513/06e57928-8cb0-41bd-b152-be16cc53e5ec) | ![image](https://github.com/rust-lang/rust/assets/1593513/37291c69-2a07-4467-a382-d9b029084a47) #### Different logo configurations | | Short crate name | Long crate name | |---------|------------------|-----------------| | Root | ![short-root] | ![long-root] | Subpage | ![short-subpage] | ![long-subpage] [short-root]: https://github.com/rust-lang/rust/assets/1593513/9e2b4fa8-f581-4106-b562-1e0372c13f79 [short-subpage]: https://github.com/rust-lang/rust/assets/1593513/8331cdb8-fa13-4671-a1e2-dcc1cdca7451 [long-root]: https://github.com/rust-lang/rust/assets/1593513/7d377fec-0f1d-4343-9f82-0e35a8f58056 [long-subpage]: https://github.com/rust-lang/rust/assets/1593513/3b3094a4-63c9-477c-8c15-b6075837df30 ##### Without a logo ![image](https://github.com/rust-lang/rust/assets/1593513/66672b79-6c59-4be8-a527-25ef6f0b04ab) ### Preview pages https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket/index.html https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket_sync_db_pools/index.html https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust-compiler/index.html https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust/std/index.html https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/tokio/index.html ## Motivation This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically). Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout). [Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html [Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018 ## Guide-level explanation This PR cleans up some of the sidebar navigation. It makes the logo in the desktop sidebar a bit smaller, and puts the crate name and version next to it (either beside it, or below it, depending on if there's space), making it clearer what clicking on it does: click the crate name to open the crate's home page. It also removes the Rust logo from non-official-Rust crates, again to make the navigation and supply chain clearer (since the crate name has been added, the logo is no longer necessary for navigation). It adds a bit more clarifying information for lateral navigation. On items that don't add their own sidebar items, it just shows its siblings directly below the crate name and logo, but for other items, it shows "In crate alloc" instead of just "In alloc". It also shows the lateral navigation tools on module pages, making modules consistent with every other item. ## Drawbacks While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex. ## Rationale and alternatives I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though. ## Prior art This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name. [`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html ## Unresolved questions Maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." This seems to be blocked on coming up with an API to do it without requiring them to host the file somewhere. ## Future possibilities Beyond this, plenty of other changes could be made to improve the layout, like * Fix things so that clicking an item in the sidebar doesn't cause it to scroll back to the top. * The [Internals demo](https://utherii.github.io/new.html) does this right: clicking an item in the sidebar changes the content area, but the sidebar itself does not change. This is nice, because clicking is cheap and I can skim the opening few paragraphs while browsing. * The layout of the docs sidebar causes trouble to implement this, because it's different on different pages, but at least fix this on the file browser. * Come up with a less cluttered way to do disclosure. There's a lot of `[-]` on the page. * We don't lack ideas to fix this one. We have *too many*. * Do a better job of separating local navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new). * A possibility: add a Back arrow next to the "In [module]" header? ![image](https://github.com/rust-lang/rust/assets/1593513/e969faf7-7722-457a-b8c6-8d962e9e1e23) * Give readers more control of how much rustdoc shows them, and giving doc authors more control of how much it generates. Basically, #115660 is great, let's do it too. But those are mostly orthogonal, not future possibilities unlocked by this change.
2 parents 2e7e0fb + 8222335 commit 6d05c43

File tree

64 files changed

+433
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+433
-99
lines changed

compiler/rustc_arena/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
1212
test(no_crate_inject, attr(deny(warnings)))
1313
)]
14+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
15+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
1416
#![feature(core_intrinsics)]
1517
#![feature(dropck_eyepatch)]
1618
#![feature(new_uninit)]

compiler/rustc_ast/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
99
test(attr(deny(warnings)))
1010
)]
11+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
12+
#![cfg_attr(not(bootstrap), allow(internal_features))]
13+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
1114
#![feature(associated_type_bounds)]
1215
#![feature(box_patterns)]
1316
#![feature(const_trait_impl)]

compiler/rustc_codegen_ssa/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
3+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
4+
#![cfg_attr(not(bootstrap), allow(internal_features))]
25
#![feature(associated_type_bounds)]
36
#![feature(box_patterns)]
47
#![feature(if_let_guard)]

compiler/rustc_driver_impl/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
//! This API is completely unstable and subject to change.
66
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
8+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
9+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
10+
#![cfg_attr(not(bootstrap), allow(internal_features))]
811
#![feature(lazy_cell)]
912
#![feature(decl_macro)]
1013
#![feature(panic_update_hook)]

compiler/rustc_errors/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//! This module contains the code for creating and emitting diagnostics.
44
55
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
6+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
7+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
68
#![feature(array_windows)]
79
#![feature(extract_if)]
810
#![feature(if_let_guard)]

compiler/rustc_fluent_macro/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
3+
#![cfg_attr(not(bootstrap), allow(internal_features))]
4+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
25
#![feature(proc_macro_diagnostic)]
36
#![feature(proc_macro_span)]
47
#![deny(rustc::untranslatable_diagnostic)]

compiler/rustc_graphviz/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@
273273
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
274274
test(attr(allow(unused_variables), deny(warnings)))
275275
)]
276+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
277+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
278+
#![cfg_attr(not(bootstrap), allow(internal_features))]
276279
#![deny(rustc::untranslatable_diagnostic)]
277280
#![deny(rustc::diagnostic_outside_of_impl)]
278281

compiler/rustc_hir_analysis/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ This API is completely unstable and subject to change.
5757

5858
#![allow(rustc::potential_query_instability)]
5959
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
60+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
61+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
62+
#![cfg_attr(not(bootstrap), allow(internal_features))]
6063
#![feature(box_patterns)]
6164
#![feature(control_flow_enum)]
6265
#![feature(if_let_guard)]

compiler/rustc_incremental/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
33
#![deny(missing_docs)]
44
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
5+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
6+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
7+
#![cfg_attr(not(bootstrap), allow(internal_features))]
58
#![feature(never_type)]
69
#![recursion_limit = "256"]
710
#![deny(rustc::untranslatable_diagnostic)]

compiler/rustc_infer/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
//! This API is completely unstable and subject to change.
1414
1515
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
16+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
17+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
18+
#![cfg_attr(not(bootstrap), allow(internal_features))]
1619
#![feature(associated_type_bounds)]
1720
#![feature(box_patterns)]
1821
#![feature(control_flow_enum)]

compiler/rustc_lint/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
2828
#![allow(rustc::potential_query_instability)]
2929
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
30+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
31+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
3032
#![feature(array_windows)]
3133
#![feature(box_patterns)]
3234
#![feature(control_flow_enum)]

compiler/rustc_llvm/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![deny(rustc::untranslatable_diagnostic)]
22
#![deny(rustc::diagnostic_outside_of_impl)]
33
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
4+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
5+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
6+
#![cfg_attr(not(bootstrap), allow(internal_features))]
47

58
// NOTE: This crate only exists to allow linking on mingw targets.
69

compiler/rustc_metadata/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
3+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
4+
#![cfg_attr(not(bootstrap), allow(internal_features))]
25
#![feature(decl_macro)]
36
#![feature(extract_if)]
47
#![feature(generators)]

compiler/rustc_middle/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
//! This API is completely unstable and subject to change.
2424
2525
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
26+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
27+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
2628
#![feature(allocator_api)]
2729
#![feature(array_windows)]
2830
#![feature(assert_matches)]

compiler/rustc_parse_format/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
html_playground_url = "https://play.rust-lang.org/",
1010
test(attr(deny(warnings)))
1111
)]
12+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
13+
#![cfg_attr(not(bootstrap), allow(internal_features))]
14+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
1215
#![deny(rustc::untranslatable_diagnostic)]
1316
#![deny(rustc::diagnostic_outside_of_impl)]
1417
// We want to be able to build this crate with a stable compiler, so no

compiler/rustc_passes/src/check_attr.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ impl CheckAttrVisitor<'_> {
11081108
| sym::html_root_url
11091109
| sym::html_no_source
11101110
| sym::test
1111+
| sym::rust_logo
11111112
if !self.check_attr_crate_level(attr, meta, hir_id) =>
11121113
{
11131114
is_valid = false;
@@ -1166,6 +1167,18 @@ impl CheckAttrVisitor<'_> {
11661167
| sym::plugins
11671168
| sym::fake_variadic => {}
11681169

1170+
sym::rust_logo => {
1171+
if !self.tcx.features().rustdoc_internals {
1172+
feature_err(
1173+
&self.tcx.sess.parse_sess,
1174+
sym::rustdoc_internals,
1175+
meta.span(),
1176+
"the `#[doc(rust_logo)]` attribute is used for Rust branding",
1177+
)
1178+
.emit();
1179+
}
1180+
}
1181+
11691182
sym::test => {
11701183
if !self.check_test_attr(meta, hir_id) {
11711184
is_valid = false;

compiler/rustc_passes/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
77
#![allow(rustc::potential_query_instability)]
88
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
9+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
10+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
11+
#![cfg_attr(not(bootstrap), allow(internal_features))]
912
#![feature(iter_intersperse)]
1013
#![feature(let_chains)]
1114
#![feature(map_try_insert)]

compiler/rustc_plugin_impl/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
//! of the Unstable Book for some examples.
88
99
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
10+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
11+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
12+
#![cfg_attr(not(bootstrap), allow(internal_features))]
1013
#![recursion_limit = "256"]
1114
#![deny(rustc::untranslatable_diagnostic)]
1215
#![deny(rustc::diagnostic_outside_of_impl)]

compiler/rustc_privacy/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
3+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
4+
#![cfg_attr(not(bootstrap), allow(internal_features))]
25
#![feature(associated_type_defaults)]
36
#![feature(rustc_private)]
47
#![feature(try_blocks)]

compiler/rustc_query_impl/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Support for serializing the dep-graph and reloading it.
22
33
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
4+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
5+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
46
// this shouldn't be necessary, but the check for `&mut _` is too naive and denies returning a function pointer that takes a mut ref
57
#![feature(const_mut_refs)]
68
#![feature(const_refs_to_cell)]

compiler/rustc_resolve/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//! Type-relative name resolution (methods, fields, associated items) happens in `rustc_hir_analysis`.
88
99
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
10+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
11+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
1012
#![feature(assert_matches)]
1113
#![feature(box_patterns)]
1214
#![feature(extract_if)]

compiler/rustc_serialize/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
html_playground_url = "https://play.rust-lang.org/",
66
test(attr(allow(unused_variables), deny(warnings)))
77
)]
8+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
9+
#![cfg_attr(not(bootstrap), allow(internal_features))]
10+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
811
#![feature(allocator_api)]
912
#![feature(associated_type_bounds)]
1013
#![feature(const_option)]

compiler/rustc_smir/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
1111
test(attr(allow(unused_variables), deny(warnings)))
1212
)]
13+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
14+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
15+
#![cfg_attr(not(bootstrap), allow(internal_features))]
1316

1417
pub mod rustc_internal;
1518

compiler/rustc_span/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
//! This API is completely unstable and subject to change.
1515
1616
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
17+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
18+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
1719
#![feature(array_windows)]
1820
#![feature(if_let_guard)]
1921
#![feature(negative_impls)]

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,7 @@ symbols! {
13271327
rust_cold_cc,
13281328
rust_eh_catch_typeinfo,
13291329
rust_eh_personality,
1330+
rust_logo,
13301331
rustc,
13311332
rustc_abi,
13321333
rustc_allocator,

compiler/rustc_symbol_mangling/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
//! DefPaths which are much more robust in the face of changes to the code base.
8989
9090
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
91+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
92+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
93+
#![cfg_attr(not(bootstrap), allow(internal_features))]
9194
#![feature(never_type)]
9295
#![recursion_limit = "256"]
9396
#![allow(rustc::potential_query_instability)]

compiler/rustc_target/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
//! LLVM.
99
1010
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
11+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
12+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
1113
#![feature(assert_matches)]
1214
#![feature(associated_type_bounds)]
1315
#![feature(exhaustive_patterns)]

compiler/rustc_trait_selection/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
//! This API is completely unstable and subject to change.
1212
1313
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
14+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
15+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
16+
#![cfg_attr(not(bootstrap), allow(internal_features))]
1417
#![feature(associated_type_bounds)]
1518
#![feature(box_patterns)]
1619
#![feature(control_flow_enum)]

compiler/rustc_ty_utils/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
//! This API is completely unstable and subject to change.
66
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
8+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
9+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
10+
#![cfg_attr(not(bootstrap), allow(internal_features))]
811
#![feature(assert_matches)]
912
#![feature(iterator_try_collect)]
1013
#![feature(let_chains)]

library/alloc/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
not(no_sync),
7979
target_has_atomic = "ptr"
8080
))]
81+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
82+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
8183
#![no_std]
8284
#![needs_allocator]
8385
// Lints:

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
test(no_crate_inject, attr(deny(warnings))),
6969
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
7070
)]
71+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
7172
#![doc(cfg_hide(
7273
not(test),
7374
any(not(feature = "miri-test-libstd"), test, doctest),

library/proc_macro/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
test(no_crate_inject, attr(deny(warnings))),
1818
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
1919
)]
20+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
21+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
2022
// This library is copied into rust-analyzer to allow loading rustc compiled proc macros.
2123
// Please avoid unstable features where possible to minimize the amount of changes necessary
2224
// to make it compile with rust-analyzer on stable.

library/std/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
test(no_crate_inject, attr(deny(warnings))),
228228
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
229229
)]
230+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
230231
#![doc(cfg_hide(
231232
not(test),
232233
not(any(test, bootstrap)),

library/test/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#![unstable(feature = "test", issue = "50297")]
1818
#![doc(test(attr(deny(warnings))))]
19+
#![cfg_attr(not(bootstrap), doc(rust_logo))]
20+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
1921
#![feature(internal_output_capture)]
2022
#![feature(staged_api)]
2123
#![feature(process_exitcode_internals)]

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

+15
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,21 @@ To do so, the `#[doc(keyword = "...")]` attribute is used. Example:
207207
mod empty_mod {}
208208
```
209209

210+
### Use the Rust logo as the crate logo
211+
212+
This is for official Rust project use only.
213+
214+
Internal Rustdoc pages like settings.html and scrape-examples-help.html show the Rust logo.
215+
This logo is tracked as a static resource. The attribute `#![doc(rust_logo)]` makes this same
216+
built-in resource act as the main logo.
217+
218+
```rust
219+
#![feature(rustdoc_internals)]
220+
#![allow(internal_features)]
221+
#![doc(rust_logo)]
222+
//! This crate has the Rust(tm) branding on it.
223+
```
224+
210225
## Effects of other nightly features
211226

212227
These nightly-only features are not primarily related to Rustdoc,

0 commit comments

Comments
 (0)