From 91b14aa6f9723e641e4fc1505f736d8b9cb8e963 Mon Sep 17 00:00:00 2001 From: "taylor.fish" Date: Sat, 24 Aug 2024 14:00:55 -0700 Subject: [PATCH] Allow `rustup doc` to search for unions Add "union" to the list of prefixes used when searching for documentation. Fixes #4002, where `rustup doc` fails to find the documentation for `std::mem::MaybeUninit`. --- src/cli/topical_doc.rs | 2 +- src/test/mock/topical_doc_data.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cli/topical_doc.rs b/src/cli/topical_doc.rs index 87215df235..b0a181f405 100644 --- a/src/cli/topical_doc.rs +++ b/src/cli/topical_doc.rs @@ -47,7 +47,7 @@ pub(crate) fn local_path(root: &Path, topic: &str) -> Result { // be changed. // https://github.com/rust-lang/rustup/issues/2076#issuecomment-546613036 let keywords_top = vec!["keyword", "primitive", "macro"]; - let keywords_mod = ["fn", "struct", "trait", "enum", "type", "constant"]; + let keywords_mod = ["fn", "struct", "trait", "enum", "type", "constant", "union"]; let topic_vec: Vec<&str> = topic.split("::").collect(); let work_path = topic_vec.iter().fold(PathBuf::new(), |acc, e| acc.join(e)); diff --git a/src/test/mock/topical_doc_data.rs b/src/test/mock/topical_doc_data.rs index 818e5f4c04..e8f93a37be 100644 --- a/src/test/mock/topical_doc_data.rs +++ b/src/test/mock/topical_doc_data.rs @@ -19,6 +19,7 @@ static TEST_CASES: &[&[&str]] = &[ &["usize", "std/primitive.usize.html"], &["eprintln", "std/macro.eprintln.html"], &["alloc::format", "alloc/macro.format.html"], + &["std::mem::MaybeUninit", "std/mem/union.MaybeUninit.html"], ]; fn repath(origin: &str) -> String {