Skip to content

Commit c810f78

Browse files
authored
Unrolled build for rust-lang#134880
Rollup merge of rust-lang#134880 - as1100k-forks:fix-rustdoc-json-path-name, r=aDotInTheVoid Made `Path::name` only have item name rather than full name Closes rust-lang#134853 This PR makes `Path::name` to only have item name rather than full name, i.e. with the following code ```rust pub mod foo { pub struct Bar; } pub fn get_bar() -> foo::Bar { foo::Bar } ``` and running `./rustdoc ./demo.rs -wjson -Zunstable-options` gives: ```json { "41": { "id": 41, "name": "get_bar", "inner": { "function": { "sig": { "inputs": [], "output": { "resolved_path": { "name": "Bar", "id": 0, "args": { "angle_bracketed": { "args": [], "constraints": [] } } } } } } } } } ``` _Information which isn't useful here was trimmed_ r? aDotInTheVoid
2 parents 3736b85 + 2c4aee9 commit c810f78

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/librustdoc/json/conversions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ impl FromClean<clean::Type> for Type {
622622
impl FromClean<clean::Path> for Path {
623623
fn from_clean(path: clean::Path, renderer: &JsonRenderer<'_>) -> Path {
624624
Path {
625-
name: path.whole_name(),
625+
name: path.last_opt().map_or(String::from(""), |s| String::from(s.as_str())),
626626
id: renderer.id_from_item_default(path.def_id().into()),
627627
args: path.segments.last().map(|args| Box::new(args.clone().args.into_json(renderer))),
628628
}

src/rustdoc-json-types/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
3030
/// This integer is incremented with every breaking change to the API,
3131
/// and is returned along with the JSON blob as [`Crate::format_version`].
3232
/// Consuming code should assert that this value matches the format version(s) that it supports.
33-
pub const FORMAT_VERSION: u32 = 37;
33+
pub const FORMAT_VERSION: u32 = 38;
3434

3535
/// The root of the emitted JSON blob.
3636
///

tests/rustdoc-json/return_private.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod secret {
66
}
77

88
//@ has "$.index[*][?(@.name=='get_secret')].inner.function"
9-
//@ is "$.index[*][?(@.name=='get_secret')].inner.function.sig.output.resolved_path.name" \"secret::Secret\"
9+
//@ is "$.index[*][?(@.name=='get_secret')].inner.function.sig.output.resolved_path.name" \"Secret\"
1010
pub fn get_secret() -> secret::Secret {
1111
secret::Secret
1212
}

0 commit comments

Comments
 (0)