Skip to content

Commit 4c71610

Browse files
committed
rustdoc: link consistently to stable/beta in diagnostic messages
1 parent 7411a9e commit 4c71610

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

src/librustdoc/clean/utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ crate fn has_doc_flag(attrs: ty::Attributes<'_>, flag: Symbol) -> bool {
544544
})
545545
}
546546

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

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
);

src/librustdoc/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,10 @@ fn usage(argv0: &str) {
605605
}
606606
println!("{}", options.usage(&format!("{} [options] <input>", argv0)));
607607
println!(" @path Read newline separated options from `path`\n");
608-
println!("More information available at https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html")
608+
println!(
609+
"More information available at {}/rustdoc/what-is-rustdoc.html",
610+
DOC_RUST_LANG_ORG_CHANNEL
611+
);
609612
}
610613

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

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)