Skip to content

Commit 34b9932

Browse files
committed
Auto merge of #85990 - jyn514:channel-replace-rustdoc, r=Manishearth
rustdoc: link consistently to stable/beta in diagnostic messages Builds on #84942. This makes the diagnostics consistent with the links.
2 parents 4e20754 + 4c71610 commit 34b9932

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

Diff for: src/librustdoc/clean/utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,8 @@ crate fn has_doc_flag(attrs: ty::Attributes<'_>, flag: Symbol) -> bool {
557557
})
558558
}
559559

560-
/// A link to `doc.rust-lang.org` that includes the channel name.
560+
/// A link to `doc.rust-lang.org` that includes the channel name. Use this instead of manual links
561+
/// so that the channel is consistent.
561562
///
562563
/// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
563564
crate const DOC_RUST_LANG_ORG_CHANNEL: &'static str = env!("DOC_RUST_LANG_ORG_CHANNEL");

Diff for: src/librustdoc/core.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,18 @@ crate fn run_global_ctxt(
399399
let mut krate = tcx.sess.time("clean_crate", || clean::krate(&mut ctxt));
400400

401401
if krate.module.doc_value().map(|d| d.is_empty()).unwrap_or(true) {
402-
let help = "The following guide may be of use:\n\
403-
https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation.html";
402+
let help = format!(
403+
"The following guide may be of use:\n\
404+
{}/rustdoc/how-to-write-documentation.html",
405+
crate::DOC_RUST_LANG_ORG_CHANNEL
406+
);
404407
tcx.struct_lint_node(
405408
crate::lint::MISSING_CRATE_LEVEL_DOCS,
406409
DocContext::as_local_hir_id(tcx, krate.module.def_id).unwrap(),
407410
|lint| {
408411
let mut diag =
409412
lint.build("no documentation found for this crate's top-level module");
410-
diag.help(help);
413+
diag.help(&help);
411414
diag.emit();
412415
},
413416
);

Diff for: src/librustdoc/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,10 @@ fn usage(argv0: &str) {
613613
}
614614
println!("{}", options.usage(&format!("{} [options] <input>", argv0)));
615615
println!(" @path Read newline separated options from `path`\n");
616-
println!("More information available at https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html")
616+
println!(
617+
"More information available at {}/rustdoc/what-is-rustdoc.html",
618+
DOC_RUST_LANG_ORG_CHANNEL
619+
);
617620
}
618621

619622
/// A result type used by several functions under `main()`.

Diff for: src/librustdoc/passes/collect_intra_doc_links.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1999,8 +1999,11 @@ fn disambiguator_error(
19991999
) {
20002000
diag_info.link_range = disambiguator_range;
20012001
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp| {
2002-
let msg = "see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators";
2003-
diag.note(msg);
2002+
let msg = format!(
2003+
"see {}/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators",
2004+
crate::DOC_RUST_LANG_ORG_CHANNEL
2005+
);
2006+
diag.note(&msg);
20042007
});
20052008
}
20062009

0 commit comments

Comments
 (0)