Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 55928be

Browse filesBrowse files
committed
fix(rustdoc): always use a channel when linking to doc.rust-lang.org
1 parent 336209e commit 55928be
Copy full SHA for 55928be

File tree

Expand file treeCollapse file tree

14 files changed

+31
-30
lines changed
Filter options
Expand file treeCollapse file tree

14 files changed

+31
-30
lines changed

‎src/librustdoc/clean/mod.rs

Copy file name to clipboardExpand all lines: src/librustdoc/clean/mod.rs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ fn can_elide_trait_object_lifetime_bound<'tcx>(
19251925
preds: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
19261926
tcx: TyCtxt<'tcx>,
19271927
) -> bool {
1928-
// Below we quote extracts from https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes
1928+
// Below we quote extracts from https://doc.rust-lang.org/stable/reference/lifetime-elision.html#default-trait-object-lifetimes
19291929

19301930
// > If the trait object is used as a type argument of a generic type then the containing type is
19311931
// > first used to try to infer a bound.

‎src/librustdoc/clean/utils.rs

Copy file name to clipboardExpand all lines: src/librustdoc/clean/utils.rs
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,9 @@ pub(crate) fn attrs_have_doc_flag<'a>(
589589
/// so that the channel is consistent.
590590
///
591591
/// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
592-
pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
593-
pub(crate) static DOC_CHANNEL: Lazy<&'static str> =
594-
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').find(|c| !c.is_empty()).unwrap());
592+
pub(crate) const DOC_RUST_LANG_ORG_VERSION: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
593+
pub(crate) static RUSTDOC_VERSION: Lazy<&'static str> =
594+
Lazy::new(|| DOC_RUST_LANG_ORG_VERSION.rsplit('/').find(|c| !c.is_empty()).unwrap());
595595

596596
/// Render a sequence of macro arms in a format suitable for displaying to the user
597597
/// as part of an item declaration.

‎src/librustdoc/core.rs

Copy file name to clipboardExpand all lines: src/librustdoc/core.rs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ pub(crate) fn run_global_ctxt(
388388
let help = format!(
389389
"The following guide may be of use:\n\
390390
{}/rustdoc/how-to-write-documentation.html",
391-
crate::DOC_RUST_LANG_ORG_CHANNEL
391+
crate::DOC_RUST_LANG_ORG_VERSION
392392
);
393393
tcx.node_lint(
394394
crate::lint::MISSING_CRATE_LEVEL_DOCS,

‎src/librustdoc/html/layout.rs

Copy file name to clipboardExpand all lines: src/librustdoc/html/layout.rs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub(crate) fn render<T: Print, S: Print>(
112112
display_krate_with_trailing_slash,
113113
display_krate_version_number,
114114
display_krate_version_extra,
115-
rust_channel: *crate::clean::utils::DOC_CHANNEL,
115+
rust_channel: *crate::clean::utils::RUSTDOC_VERSION,
116116
rustdoc_version,
117117
}
118118
.render()

‎src/librustdoc/html/render/context.rs

Copy file name to clipboardExpand all lines: src/librustdoc/html/render/context.rs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::html::render::write_shared::write_shared;
3232
use crate::html::url_parts_builder::UrlPartsBuilder;
3333
use crate::html::{layout, sources, static_files};
3434
use crate::scrape_examples::AllCallLocations;
35-
use crate::try_err;
35+
use crate::{DOC_RUST_LANG_ORG_VERSION, try_err};
3636

3737
/// Major driving force in all rustdoc rendering. This contains information
3838
/// about where in the tree-like hierarchy rendering is occurring and controls
@@ -730,7 +730,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
730730
<noscript>\
731731
<section>\
732732
<p>You need to enable JavaScript to use keyboard commands or search.</p>\
733-
<p>For more information, browse the <a href=\"https://doc.rust-lang.org/rustdoc/\">rustdoc handbook</a>.</p>\
733+
<p>For more information, browse the <a href=\"{DOC_RUST_LANG_ORG_VERSION}/rustdoc/\">rustdoc handbook</a>.</p>\
734734
</section>\
735735
</noscript>",
736736
)

‎src/librustdoc/html/render/mod.rs

Copy file name to clipboardExpand all lines: src/librustdoc/html/render/mod.rs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ use crate::html::markdown::{
7979
use crate::html::static_files::SCRAPE_EXAMPLES_HELP_MD;
8080
use crate::html::{highlight, sources};
8181
use crate::scrape_examples::{CallData, CallLocation};
82-
use crate::{DOC_RUST_LANG_ORG_CHANNEL, try_none};
82+
use crate::{DOC_RUST_LANG_ORG_VERSION, try_none};
8383

8484
pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
8585
crate::html::format::display_fn(move |f| {
@@ -481,7 +481,7 @@ fn scrape_examples_help(shared: &SharedContext<'_>) -> String {
481481
content.push_str(&format!(
482482
"## More information\n\n\
483483
If you want more information about this feature, please read the [corresponding chapter in \
484-
the Rustdoc book]({DOC_RUST_LANG_ORG_CHANNEL}/rustdoc/scraped-examples.html)."
484+
the Rustdoc book]({DOC_RUST_LANG_ORG_VERSION}/rustdoc/scraped-examples.html)."
485485
));
486486

487487
let mut ids = IdMap::default();

‎src/librustdoc/html/render/print_item.rs

Copy file name to clipboardExpand all lines: src/librustdoc/html/render/print_item.rs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
944944
<a href=\"{base}/reference/items/traits.html#object-safety\">dyn compatible</a>.</p>\
945945
<p><i>In older versions of Rust, dyn compatibility was called \"object safety\", \
946946
so this trait is not object safe.</i></p></div>",
947-
base = crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL
947+
base = crate::clean::utils::DOC_RUST_LANG_ORG_VERSION
948948
),
949949
);
950950
}

‎src/librustdoc/html/static/js/main.js

Copy file name to clipboardExpand all lines: src/librustdoc/html/static/js/main.js
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,10 +1358,10 @@ function preLoadCss(cssUrl) {
13581358

13591359
function buildHelpMenu() {
13601360
const book_info = document.createElement("span");
1361-
const channel = getVar("channel");
1361+
const drloChannel = `https://doc.rust-lang.org/${getVar("channel")}`;
13621362
book_info.className = "top";
13631363
book_info.innerHTML = `You can find more information in \
1364-
<a href="https://doc.rust-lang.org/${channel}/rustdoc/">the rustdoc book</a>.`;
1364+
<a href="${drloChannel}/rustdoc/">the rustdoc book</a>.`;
13651365

13661366
const shortcuts = [
13671367
["?", "Show this help dialog"],
@@ -1381,8 +1381,8 @@ function preLoadCss(cssUrl) {
13811381
div_shortcuts.innerHTML = "<h2>Keyboard Shortcuts</h2><dl>" + shortcuts + "</dl></div>";
13821382

13831383
const infos = [
1384-
`For a full list of all search features, take a look <a \
1385-
href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.html">here</a>.`,
1384+
`For a full list of all search features, take a look \
1385+
<a href="${drloChannel}/rustdoc/read-documentation/search.html">here</a>.`,
13861386
"Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to \
13871387
restrict the search to a given item kind.",
13881388
"Accepted kinds are: <code>fn</code>, <code>mod</code>, <code>struct</code>, \
@@ -1392,10 +1392,10 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
13921392
<code>-&gt; vec</code> or <code>String, enum:Cow -&gt; bool</code>)",
13931393
"You can look for items with an exact name by putting double quotes around \
13941394
your request: <code>\"string\"</code>",
1395-
"Look for functions that accept or return \
1396-
<a href=\"https://doc.rust-lang.org/std/primitive.slice.html\">slices</a> and \
1397-
<a href=\"https://doc.rust-lang.org/std/primitive.array.html\">arrays</a> by writing \
1398-
square brackets (e.g., <code>-&gt; [u8]</code> or <code>[] -&gt; Option</code>)",
1395+
`Look for functions that accept or return \
1396+
<a href="${drloChannel}/std/primitive.slice.html">slices</a> and \
1397+
<a href="${drloChannel}/std/primitive.array.html">arrays</a> by writing square \
1398+
brackets (e.g., <code>-&gt; [u8]</code> or <code>[] -&gt; Option</code>)`,
13991399
"Look for items inside another one by searching for a path: <code>vec::Vec</code>",
14001400
].map(x => "<p>" + x + "</p>").join("");
14011401
const div_infos = document.createElement("div");

‎src/librustdoc/html/static/js/search.js

Copy file name to clipboardExpand all lines: src/librustdoc/html/static/js/search.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ignore-tidy-filelength
2-
/* global addClass, getNakedUrl, getSettingValue */
2+
/* global addClass, getNakedUrl, getSettingValue, getVar */
33
/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi, exports */
44

55
"use strict";
@@ -4408,17 +4408,18 @@ ${item.displayPath}<span class="${type}">${name}</span>\
44084408
}
44094409
});
44104410
} else if (query.error === null) {
4411+
const dlroChannel = `https://doc.rust-lang.org/${getVar("channel")}`;
44114412
output.className = "search-failed" + extraClass;
44124413
output.innerHTML = "No results :(<br/>" +
44134414
"Try on <a href=\"https://duckduckgo.com/?q=" +
44144415
encodeURIComponent("rust " + query.userQuery) +
44154416
"\">DuckDuckGo</a>?<br/><br/>" +
44164417
"Or try looking in one of these:<ul><li>The <a " +
4417-
"href=\"https://doc.rust-lang.org/reference/index.html\">Rust Reference</a> " +
4418+
`href=\"${dlroChannel}/reference/index.html\">Rust Reference</a> ` +
44184419
" for technical details about the language.</li><li><a " +
4419-
"href=\"https://doc.rust-lang.org/rust-by-example/index.html\">Rust By " +
4420+
`href=\"${dlroChannel}/rust-by-example/index.html\">Rust By ` +
44204421
"Example</a> for expository code examples.</a></li><li>The <a " +
4421-
"href=\"https://doc.rust-lang.org/book/index.html\">Rust Book</a> for " +
4422+
`href=\"${dlroChannel}/book/index.html\">Rust Book</a> for ` +
44224423
"introductions to language features and the language itself.</li><li><a " +
44234424
"href=\"https://docs.rs\">Docs.rs</a> for documentation of crates released on" +
44244425
" <a href=\"https://crates.io/\">crates.io</a>.</li></ul>";

‎src/librustdoc/html/templates/type_layout.html

Copy file name to clipboardExpand all lines: src/librustdoc/html/templates/type_layout.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h2 id="layout" class="section-header"> {# #}
1010
unstable</strong> and may even differ between compilations. {#+ #}
1111
The only exception is types with certain <code>repr(...)</code> {#+ #}
1212
attributes. Please see the Rust Reference's {#+ #}
13-
<a href="https://doc.rust-lang.org/reference/type-layout.html">“Type Layout”</a> {#+ #}
13+
<a href="{{ crate::DOC_RUST_LANG_ORG_VERSION }}/reference/type-layout.html">“Type Layout”</a> {#+ #}
1414
chapter for details on type layout guarantees. {# #}
1515
</p> {# #}
1616
</div> {# #}

‎src/librustdoc/html/templates/type_layout_size.html

Copy file name to clipboardExpand all lines: src/librustdoc/html/templates/type_layout_size.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
{{ size +}} bytes
88
{% endif %}
99
{% if is_uninhabited %}
10-
{# +#} (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)
10+
{# +#} (<a href="{{ crate::DOC_RUST_LANG_ORG_VERSION }}/reference/glossary.html#uninhabited">uninhabited</a>)
1111
{% endif %}
1212
{% endif %}

‎src/librustdoc/lib.rs

Copy file name to clipboardExpand all lines: src/librustdoc/lib.rs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use rustc_session::config::{ErrorOutputType, RustcOptGroup, make_crate_type_opti
8383
use rustc_session::{EarlyDiagCtxt, getopts};
8484
use tracing::info;
8585

86-
use crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL;
86+
use crate::clean::utils::DOC_RUST_LANG_ORG_VERSION;
8787

8888
/// A macro to create a FxHashMap.
8989
///
@@ -704,7 +704,7 @@ fn usage(argv0: &str) {
704704
println!("{}", options.usage(&format!("{argv0} [options] <input>")));
705705
println!(" @path Read newline separated options from `path`\n");
706706
println!(
707-
"More information available at {DOC_RUST_LANG_ORG_CHANNEL}/rustdoc/what-is-rustdoc.html",
707+
"More information available at {DOC_RUST_LANG_ORG_VERSION}/rustdoc/what-is-rustdoc.html",
708708
);
709709
}
710710

‎src/librustdoc/passes/collect_intra_doc_links.rs

Copy file name to clipboardExpand all lines: src/librustdoc/passes/collect_intra_doc_links.rs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2168,7 +2168,7 @@ fn disambiguator_error(
21682168
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp, _link_range| {
21692169
let msg = format!(
21702170
"see {}/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators",
2171-
crate::DOC_RUST_LANG_ORG_CHANNEL
2171+
crate::DOC_RUST_LANG_ORG_VERSION
21722172
);
21732173
diag.note(msg);
21742174
});

‎tests/rustdoc/type-layout.rs

Copy file name to clipboardExpand all lines: tests/rustdoc/type-layout.rs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ pub enum WithNiche {
8585
}
8686

8787
//@ hasraw type_layout/enum.Uninhabited.html 'Size: '
88-
//@ hasraw - '0 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)'
88+
//@ hasraw - '0 bytes (<a href="{{channel}}/reference/glossary.html#uninhabited">uninhabited</a>)'
8989
pub enum Uninhabited {}
9090

9191
//@ hasraw type_layout/struct.Uninhabited2.html 'Size: '
92-
//@ hasraw - '8 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)'
92+
//@ hasraw - '8 bytes (<a href="{{channel}}/reference/glossary.html#uninhabited">uninhabited</a>)'
9393
pub struct Uninhabited2(std::convert::Infallible, u64);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.