Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use intra-doc-link to fix broken links #74061

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ impl str {
/// While doing so, it attempts to find matches of a pattern. If it finds any, it
/// replaces them with the replacement string slice.
///
/// [`String`]: string/struct.String.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -280,8 +278,6 @@ impl str {
/// While doing so, it attempts to find matches of a pattern. If it finds any, it
/// replaces them with the replacement string slice at most `count` times.
///
/// [`String`]: string/struct.String.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -324,8 +320,6 @@ impl str {
/// the case, this function returns a [`String`] instead of modifying the
/// parameter in-place.
///
/// [`String`]: string/struct.String.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -411,8 +405,6 @@ impl str {
/// the case, this function returns a [`String`] instead of modifying the
/// parameter in-place.
///
/// [`String`]: string/struct.String.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -459,8 +451,7 @@ impl str {

/// Converts a [`Box<str>`] into a [`String`] without copying or allocating.
///
/// [`String`]: string/struct.String.html
/// [`Box<str>`]: boxed/struct.Box.html
/// [`Box<str>`]: Box
///
/// # Examples
///
Expand All @@ -485,8 +476,6 @@ impl str {
///
/// This function will panic if the capacity would overflow.
///
/// [`String`]: string/struct.String.html
///
/// # Examples
///
/// Basic usage:
Expand Down
55 changes: 15 additions & 40 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ use crate::vec::Vec;
/// contents of the string. It has a close relationship with its borrowed
/// counterpart, the primitive [`str`].
///
/// [`str`]: ../../std/primitive.str.html
///
/// # Examples
///
/// You can create a `String` from a literal string with [`String::from`]:
Expand All @@ -88,7 +86,6 @@ use crate::vec::Vec;
/// ```
///
/// [`String::from`]: #method.from
/// [`char`]: ../../std/primitive.char.html
/// [`push`]: #method.push
/// [`push_str`]: #method.push_str
///
Expand Down Expand Up @@ -128,8 +125,8 @@ use crate::vec::Vec;
/// The [`bytes`] and [`chars`] methods return iterators over the first
/// two, respectively.
///
/// [`bytes`]: #method.bytes
/// [`chars`]: #method.chars
/// [`bytes`]: str::bytes
/// [`chars`]: str::chars
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In alloc, this points to https://doc.rust-lang.org/nightly/std/primitive.str.html#method.bytes .
But in std, this points to absolute local link: http://0.0.0.0:8000/home/lzutao/fork/rust/compiler/src/liballoc/std/primitive.str.html#method.bytes

And yes, I run http server in doc directory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please file an issue for this bug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is related to cross crate re-exports. So I bet the behavior will change when #73101 lands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After stage1, the location in std is Ok http://0.0.0.0:8000/std/primitive.str.html#method.bytes .

///
/// # Deref
///
Expand Down Expand Up @@ -215,7 +212,7 @@ use crate::vec::Vec;
/// assert_eq!(String::from("Once upon a time..."), s);
/// ```
///
/// [`as_ptr`]: #method.as_ptr
/// [`as_ptr`]: str::as_ptr
/// [`len`]: #method.len
/// [`capacity`]: #method.capacity
///
Expand Down Expand Up @@ -274,9 +271,11 @@ use crate::vec::Vec;
///
/// Here, there's no need to allocate more memory inside the loop.
///
/// [`char`]: type@char
/// [`str`]: ../../std/primitive.str.html
/// [`&str`]: ../../std/primitive.str.html
/// [`Deref`]: ../../std/ops/trait.Deref.html
/// [`as_str()`]: struct.String.html#method.as_str
/// [`Deref`]: core::ops::Deref
/// [`as_str()`]: #method.as_str
#[derive(PartialOrd, Eq, Ord)]
#[cfg_attr(not(test), rustc_diagnostic_item = "string_type")]
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -302,7 +301,6 @@ pub struct String {
///
/// [`Utf8Error`]: ../../std/str/struct.Utf8Error.html
/// [`std::str`]: ../../std/str/index.html
/// [`u8`]: ../../std/primitive.u8.html
/// [`&str`]: ../../std/primitive.str.html
/// [`utf8_error`]: #method.utf8_error
///
Expand Down Expand Up @@ -481,13 +479,11 @@ impl String {
///
/// [`from_utf8_unchecked`]: struct.String.html#method.from_utf8_unchecked
/// [`String`]: struct.String.html
/// [`u8`]: ../../std/primitive.u8.html
/// [`Vec<u8>`]: ../../std/vec/struct.Vec.html
/// [`Vec<u8>`]: Vec
/// [`&str`]: ../../std/primitive.str.html
/// [`str::from_utf8`]: ../../std/str/fn.from_utf8.html
/// [`into_bytes`]: struct.String.html#method.into_bytes
/// [`FromUtf8Error`]: struct.FromUtf8Error.html
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
Expand All @@ -506,9 +502,8 @@ impl String {
/// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with
/// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], which looks like this: �
///
/// [`u8`]: ../../std/primitive.u8.html
/// [byteslice]: ../../std/primitive.slice.html
/// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
/// [U+FFFD]: core::char::REPLACEMENT_CHARACTER
///
/// If you are sure that the byte slice is valid UTF-8, and you don't want
/// to incur the overhead of the conversion, there is an unsafe version
Expand All @@ -523,7 +518,7 @@ impl String {
/// it's already valid UTF-8, we don't need a new allocation. This return
/// type allows us to handle both cases.
///
/// [`Cow<'a, str>`]: ../../std/borrow/enum.Cow.html
/// [`Cow<'a, str>`]: crate::borrow::Cow
///
/// # Examples
///
Expand Down Expand Up @@ -583,8 +578,6 @@ impl String {
/// Decode a UTF-16 encoded vector `v` into a `String`, returning [`Err`]
/// if `v` contains any invalid data.
///
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -624,8 +617,8 @@ impl String {
/// conversion requires a memory allocation.
///
/// [`from_utf8_lossy`]: #method.from_utf8_lossy
/// [`Cow<'a, str>`]: ../borrow/enum.Cow.html
/// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
/// [`Cow<'a, str>`]: crate::borrow::Cow
/// [U+FFFD]: core::char::REPLACEMENT_CHARACTER
///
/// # Examples
///
Expand Down Expand Up @@ -1076,8 +1069,6 @@ impl String {

/// Appends the given [`char`] to the end of this `String`.
///
/// [`char`]: ../../std/primitive.char.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -1133,8 +1124,6 @@ impl String {
///
/// Panics if `new_len` does not lie on a [`char`] boundary.
///
/// [`char`]: ../../std/primitive.char.html
///
/// # Examples
///
/// Basic usage:
Expand All @@ -1159,8 +1148,6 @@ impl String {
///
/// Returns [`None`] if this `String` is empty.
///
/// [`None`]: ../../std/option/enum.Option.html#variant.None
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -1195,8 +1182,6 @@ impl String {
/// Panics if `idx` is larger than or equal to the `String`'s length,
/// or if it does not lie on a [`char`] boundary.
///
/// [`char`]: ../../std/primitive.char.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -1297,8 +1282,6 @@ impl String {
/// Panics if `idx` is larger than the `String`'s length, or if it does not
/// lie on a [`char`] boundary.
///
/// [`char`]: ../../std/primitive.char.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -1346,8 +1329,6 @@ impl String {
/// Panics if `idx` is larger than the `String`'s length, or if it does not
/// lie on a [`char`] boundary.
///
/// [`char`]: ../../std/primitive.char.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -1507,8 +1488,6 @@ impl String {
/// Panics if the starting point or end point do not lie on a [`char`]
/// boundary, or if they're out of bounds.
///
/// [`char`]: ../../std/primitive.char.html
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -1567,9 +1546,6 @@ impl String {
/// Panics if the starting point or end point do not lie on a [`char`]
/// boundary, or if they're out of bounds.
///
/// [`char`]: ../../std/primitive.char.html
/// [`Vec::splice`]: ../../std/vec/struct.Vec.html#method.splice
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -1610,7 +1586,7 @@ impl String {
///
/// This will drop any excess capacity.
///
/// [`Box`]: ../../std/boxed/struct.Box.html
/// [`Box`]: crate::boxed::Box
/// [`str`]: ../../std/primitive.str.html
///
/// # Examples
Expand Down Expand Up @@ -1682,7 +1658,6 @@ impl FromUtf8Error {
///
/// [`Utf8Error`]: ../../std/str/struct.Utf8Error.html
/// [`std::str`]: ../../std/str/index.html
/// [`u8`]: ../../std/primitive.u8.html
/// [`&str`]: ../../std/primitive.str.html
///
/// # Examples
Expand Down Expand Up @@ -2187,7 +2162,7 @@ impl ops::DerefMut for String {
///
/// This alias exists for backwards compatibility, and may be eventually deprecated.
///
/// [`Infallible`]: ../../core/convert/enum.Infallible.html
/// [`Infallible`]: core::convert::Infallible
#[stable(feature = "str_parse_error", since = "1.5.0")]
pub type ParseError = core::convert::Infallible;

Expand All @@ -2207,7 +2182,7 @@ impl FromStr for String {
/// [`Display`] should be implemented instead, and you get the `ToString`
/// implementation for free.
///
/// [`Display`]: ../../std/fmt/trait.Display.html
/// [`Display`]: crate::fmt::Display
#[stable(feature = "rust1", since = "1.0.0")]
pub trait ToString {
/// Converts the given value to a `String`.
Expand Down
8 changes: 1 addition & 7 deletions src/tools/linkchecker/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,7 @@ fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Opti
// Unfortunately we're not 100% full of valid links today to we need a few
// exceptions to get this past `make check` today.
// FIXME(#32129)
if file.ends_with("std/io/struct.IoSlice.html")
|| file.ends_with("std/string/struct.String.html")
{
return None;
}
// FIXME(#32553)
if file.ends_with("alloc/string/struct.String.html") {
if file.ends_with("std/io/struct.IoSlice.html") {
return None;
}
// FIXME(#32130)
Expand Down