From d5e7aee42792af1065f56163cd422950ef44e94a Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Sat, 27 Jun 2020 08:47:26 -0700 Subject: [PATCH 1/6] docs: Fix broken [pattern] link --- src/libcore/str/mod.rs | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 6c4b28499a60b..aca7bf8f952dc 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -3013,7 +3013,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Examples /// @@ -3040,7 +3040,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Examples /// @@ -3066,7 +3066,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Examples /// @@ -3096,7 +3096,7 @@ impl str { /// /// [`None`]: option/enum.Option.html#variant.None /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Examples /// @@ -3145,7 +3145,7 @@ impl str { /// /// [`None`]: option/enum.Option.html#variant.None /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Examples /// @@ -3191,7 +3191,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Iterator behavior /// @@ -3313,7 +3313,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Examples /// @@ -3353,7 +3353,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Iterator behavior /// @@ -3407,7 +3407,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// Equivalent to [`split`], except that the trailing substring /// is skipped if empty. @@ -3454,7 +3454,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// Equivalent to [`split`], except that the trailing substring is /// skipped if empty. @@ -3503,7 +3503,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Iterator behavior /// @@ -3556,7 +3556,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Iterator behavior /// @@ -3604,7 +3604,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Iterator behavior /// @@ -3643,7 +3643,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Iterator behavior /// @@ -3687,7 +3687,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Iterator behavior /// @@ -3732,7 +3732,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Iterator behavior /// @@ -3953,7 +3953,7 @@ impl str { /// or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Examples /// @@ -4001,7 +4001,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Text directionality /// @@ -4046,7 +4046,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Examples /// @@ -4074,7 +4074,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Examples /// @@ -4101,7 +4101,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Text directionality /// @@ -4150,7 +4150,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Text directionality /// @@ -4187,7 +4187,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: str/pattern/index.html + /// [pattern]: ../str/pattern/index.html /// /// # Text directionality /// From fb26b0c479fc8694359434973f8a156b9e538ae0 Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Sat, 4 Jul 2020 07:26:24 -0700 Subject: [PATCH 2/6] Use intra-doc-links in place of explicit paths These docs are available from two different paths: ``` /std/string/struct.String.html /std/primitive.str.html ``` Because they're at different levels, we can't construct a single relative path that works for both. However, we can ask the tooling to generate the correct relative path for each source with an `intra-doc-link`. --- src/libcore/str/mod.rs | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index aca7bf8f952dc..de64478c6fd08 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -3013,7 +3013,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Examples /// @@ -3040,7 +3040,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Examples /// @@ -3066,7 +3066,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Examples /// @@ -3096,7 +3096,7 @@ impl str { /// /// [`None`]: option/enum.Option.html#variant.None /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Examples /// @@ -3145,7 +3145,7 @@ impl str { /// /// [`None`]: option/enum.Option.html#variant.None /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Examples /// @@ -3191,7 +3191,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Iterator behavior /// @@ -3313,7 +3313,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Examples /// @@ -3353,7 +3353,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Iterator behavior /// @@ -3407,7 +3407,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// Equivalent to [`split`], except that the trailing substring /// is skipped if empty. @@ -3454,7 +3454,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// Equivalent to [`split`], except that the trailing substring is /// skipped if empty. @@ -3503,7 +3503,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Iterator behavior /// @@ -3556,7 +3556,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Iterator behavior /// @@ -3604,7 +3604,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Iterator behavior /// @@ -3643,7 +3643,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Iterator behavior /// @@ -3687,7 +3687,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Iterator behavior /// @@ -3732,7 +3732,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Iterator behavior /// @@ -3953,7 +3953,7 @@ impl str { /// or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Examples /// @@ -4001,7 +4001,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Text directionality /// @@ -4046,7 +4046,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Examples /// @@ -4074,7 +4074,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Examples /// @@ -4101,7 +4101,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Text directionality /// @@ -4150,7 +4150,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Text directionality /// @@ -4187,7 +4187,7 @@ impl str { /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html - /// [pattern]: ../str/pattern/index.html + /// [pattern]: crate::str::pattern /// /// # Text directionality /// From c5660155d099e8f9c0aef32debe586763b184213 Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Sat, 4 Jul 2020 11:47:21 -0700 Subject: [PATCH 3/6] Use more intra-doc-links See fb26b0c. This commit also removes the exclusion for the String docs page, but there's still a few broken links. --- src/libcore/str/mod.rs | 26 -------------------------- src/tools/linkchecker/main.rs | 1 - 2 files changed, 27 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index de64478c6fd08..65f8951675025 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -468,7 +468,6 @@ Section: Iterators /// An iterator over the [`char`]s of a string slice. /// -/// [`char`]: ../../std/primitive.char.html /// /// This struct is created by the [`chars`] method on [`str`]. /// See its documentation for more. @@ -3012,7 +3011,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3039,7 +3037,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3065,7 +3062,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3094,8 +3090,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`None`]: option/enum.Option.html#variant.None - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3143,8 +3137,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`None`]: option/enum.Option.html#variant.None - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3190,7 +3182,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3312,7 +3303,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3352,7 +3342,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3406,7 +3395,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// Equivalent to [`split`], except that the trailing substring @@ -3453,7 +3441,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// Equivalent to [`split`], except that the trailing substring is @@ -3502,7 +3489,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3555,7 +3541,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3603,7 +3588,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3642,7 +3626,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3686,7 +3669,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3731,7 +3713,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3952,7 +3933,6 @@ impl str { /// The [pattern] can be a [`char`], a slice of [`char`]s, or a function /// or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -4000,7 +3980,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Text directionality @@ -4045,7 +4024,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -4073,7 +4051,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -4100,7 +4077,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Text directionality @@ -4149,7 +4125,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Text directionality @@ -4186,7 +4161,6 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Text directionality diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index 9e4e2c433fbed..f97957790167d 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -121,7 +121,6 @@ fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Opti // whitelists 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; } From d47807faf6efd39440c92547f2452b0f5ba6df50 Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Sun, 5 Jul 2020 09:01:36 -0700 Subject: [PATCH 4/6] fix rustfmt --- src/tools/linkchecker/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index f97957790167d..3d6de5bb92b15 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -120,8 +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 // whitelists to get this past `make check` today. // FIXME(#32129) - if file.ends_with("std/io/struct.IoSlice.html") - { + if file.ends_with("std/io/struct.IoSlice.html") { return None; } // FIXME(#32553) From e8b9bead882f4059b6aa01079565f745f95d8ccb Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Sun, 5 Jul 2020 09:09:09 -0700 Subject: [PATCH 5/6] Use intra-doc-links for char methods At least locally, this required the fix in librustdoc: else, I was seeing broken links pointing into the source of the module being documented rather than linking to the `std/primitive.char.html#method.FOO` page as was likely intended. --- src/libcore/str/mod.rs | 6 ------ src/librustdoc/clean/types.rs | 10 ++++++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 65f8951675025..a9ae409bde149 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -4345,8 +4345,6 @@ impl str { /// Note: only extended grapheme codepoints that begin the string will be /// escaped. /// - /// [`char::escape_debug`]: ../std/primitive.char.html#method.escape_debug - /// /// # Examples /// /// As an iterator: @@ -4391,8 +4389,6 @@ impl str { /// Return an iterator that escapes each char in `self` with [`char::escape_default`]. /// - /// [`char::escape_default`]: ../std/primitive.char.html#method.escape_default - /// /// # Examples /// /// As an iterator: @@ -4429,8 +4425,6 @@ impl str { /// Return an iterator that escapes each char in `self` with [`char::escape_unicode`]. /// - /// [`char::escape_unicode`]: ../std/primitive.char.html#method.escape_unicode - /// /// # Examples /// /// As an iterator: diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 6dec016cc2ee3..34f91bfec5a88 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -628,6 +628,7 @@ impl Attributes { /// Cache must be populated before call pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> { use crate::html::format::href; + use crate::html::render::CURRENT_DEPTH; self.links .iter() @@ -648,12 +649,13 @@ impl Attributes { if let Some(ref fragment) = *fragment { let cache = cache(); let url = match cache.extern_locations.get(krate) { - Some(&(_, ref src, ExternalLocation::Local)) => { - src.to_str().expect("invalid file path") + Some(&(_, _, ExternalLocation::Local)) => { + let depth = CURRENT_DEPTH.with(|l| l.get()); + "../".repeat(depth) } - Some(&(_, _, ExternalLocation::Remote(ref s))) => s, + Some(&(_, _, ExternalLocation::Remote(ref s))) => s.to_string(), Some(&(_, _, ExternalLocation::Unknown)) | None => { - "https://doc.rust-lang.org/nightly" + String::from("https://doc.rust-lang.org/nightly") } }; // This is a primitive so the url is done "by hand". From 6b6b8c9f8ae7a47e57b45fd24bfcafea1bb134f2 Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Sun, 5 Jul 2020 17:34:27 -0700 Subject: [PATCH 6/6] Revert all but [pattern] fixes --- src/libcore/str/mod.rs | 32 ++++++++++++++++++++++++++++++++ src/librustdoc/clean/types.rs | 10 ++++------ src/tools/linkchecker/main.rs | 4 +++- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index a9ae409bde149..de64478c6fd08 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -468,6 +468,7 @@ Section: Iterators /// An iterator over the [`char`]s of a string slice. /// +/// [`char`]: ../../std/primitive.char.html /// /// This struct is created by the [`chars`] method on [`str`]. /// See its documentation for more. @@ -3011,6 +3012,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3037,6 +3039,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3062,6 +3065,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3090,6 +3094,8 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`None`]: option/enum.Option.html#variant.None + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3137,6 +3143,8 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`None`]: option/enum.Option.html#variant.None + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3182,6 +3190,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3303,6 +3312,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3342,6 +3352,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3395,6 +3406,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// Equivalent to [`split`], except that the trailing substring @@ -3441,6 +3453,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// Equivalent to [`split`], except that the trailing substring is @@ -3489,6 +3502,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3541,6 +3555,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3588,6 +3603,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3626,6 +3642,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3669,6 +3686,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3713,6 +3731,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Iterator behavior @@ -3933,6 +3952,7 @@ impl str { /// The [pattern] can be a [`char`], a slice of [`char`]s, or a function /// or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -3980,6 +4000,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Text directionality @@ -4024,6 +4045,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -4051,6 +4073,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Examples @@ -4077,6 +4100,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Text directionality @@ -4125,6 +4149,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Text directionality @@ -4161,6 +4186,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// + /// [`char`]: primitive.char.html /// [pattern]: crate::str::pattern /// /// # Text directionality @@ -4345,6 +4371,8 @@ impl str { /// Note: only extended grapheme codepoints that begin the string will be /// escaped. /// + /// [`char::escape_debug`]: ../std/primitive.char.html#method.escape_debug + /// /// # Examples /// /// As an iterator: @@ -4389,6 +4417,8 @@ impl str { /// Return an iterator that escapes each char in `self` with [`char::escape_default`]. /// + /// [`char::escape_default`]: ../std/primitive.char.html#method.escape_default + /// /// # Examples /// /// As an iterator: @@ -4425,6 +4455,8 @@ impl str { /// Return an iterator that escapes each char in `self` with [`char::escape_unicode`]. /// + /// [`char::escape_unicode`]: ../std/primitive.char.html#method.escape_unicode + /// /// # Examples /// /// As an iterator: diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 34f91bfec5a88..6dec016cc2ee3 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -628,7 +628,6 @@ impl Attributes { /// Cache must be populated before call pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> { use crate::html::format::href; - use crate::html::render::CURRENT_DEPTH; self.links .iter() @@ -649,13 +648,12 @@ impl Attributes { if let Some(ref fragment) = *fragment { let cache = cache(); let url = match cache.extern_locations.get(krate) { - Some(&(_, _, ExternalLocation::Local)) => { - let depth = CURRENT_DEPTH.with(|l| l.get()); - "../".repeat(depth) + Some(&(_, ref src, ExternalLocation::Local)) => { + src.to_str().expect("invalid file path") } - Some(&(_, _, ExternalLocation::Remote(ref s))) => s.to_string(), + Some(&(_, _, ExternalLocation::Remote(ref s))) => s, Some(&(_, _, ExternalLocation::Unknown)) | None => { - String::from("https://doc.rust-lang.org/nightly") + "https://doc.rust-lang.org/nightly" } }; // This is a primitive so the url is done "by hand". diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index 3d6de5bb92b15..9e4e2c433fbed 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -120,7 +120,9 @@ 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 // whitelists to get this past `make check` today. // FIXME(#32129) - if file.ends_with("std/io/struct.IoSlice.html") { + if file.ends_with("std/io/struct.IoSlice.html") + || file.ends_with("std/string/struct.String.html") + { return None; } // FIXME(#32553)