1
Fork 0
rust/src/test/rustdoc/intra-doc/non-path-primitives.rs
Joshua Nelson 7411a9e7cc rustdoc: link to stable/beta docs consistently in documentation
## User-facing changes

- Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as).
- Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels).
- Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links.

Note that "links" includes both intra-doc links and rustdoc's own
automatically generated hyperlinks.

 ## Implementation changes

- Update the testsuite to allow linking to /beta and /1.52.1 in docs
- Use an html_root_url for the standard library that's dependent on the channel

  This avoids linking to nightly docs on stable.

- Update rustdoc to use channel-dependent links for primitives from an
  unknown crate

- Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync
- Include doc.rust-lang.org in the channel
2021-06-04 14:18:21 -04:00

46 lines
1.7 KiB
Rust

#![crate_name = "foo"]
#![feature(intra_doc_pointers)]
#![deny(rustdoc::broken_intra_doc_links)]
// @has foo/index.html '//a[@href="{{channel}}/std/primitive.slice.html#method.rotate_left"]' 'slice::rotate_left'
//! [slice::rotate_left]
// @has - '//a[@href="{{channel}}/std/primitive.array.html#method.map"]' 'array::map'
//! [array::map]
// @has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'owned str'
// @has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'str ref'
// @has - '//a[@href="{{channel}}/std/primitive.str.html#method.is_empty"]' 'str::is_empty'
// @has - '//a[@href="{{channel}}/std/primitive.str.html#method.len"]' '&str::len'
//! [owned str][str]
//! [str ref][&str]
//! [str::is_empty]
//! [&str::len]
// @has - '//a[@href="{{channel}}/std/primitive.pointer.html#method.is_null"]' 'pointer::is_null'
// @has - '//a[@href="{{channel}}/std/primitive.pointer.html#method.is_null"]' '*const::is_null'
// @has - '//a[@href="{{channel}}/std/primitive.pointer.html#method.is_null"]' '*mut::is_null'
//! [pointer::is_null]
//! [*const::is_null]
//! [*mut::is_null]
// @has - '//a[@href="{{channel}}/std/primitive.unit.html"]' 'unit'
//! [unit]
// @has - '//a[@href="{{channel}}/std/primitive.tuple.html"]' 'tuple'
//! [tuple]
// @has - '//a[@href="{{channel}}/std/primitive.reference.html"]' 'reference'
// @has - '//a[@href="{{channel}}/std/primitive.reference.html"]' '&'
// @has - '//a[@href="{{channel}}/std/primitive.reference.html"]' '&mut'
//! [reference]
//! [&]
//! [&mut]
// @has - '//a[@href="{{channel}}/std/primitive.fn.html"]' 'fn'
//! [fn]
// @has - '//a[@href="{{channel}}/std/primitive.never.html"]' 'never'
// @has - '//a[@href="{{channel}}/std/primitive.never.html"]' '!'
//! [never]
//! [!]