mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #134880 - as1100k-forks:fix-rustdoc-json-path-name, r=aDotInTheVoid
Made `Path::name` only have item name rather than full name Closes #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
This commit is contained in:
@@ -622,7 +622,7 @@ fn from_clean(ty: clean::Type, renderer: &JsonRenderer<'_>) -> Self {
|
||||
impl FromClean<clean::Path> for Path {
|
||||
fn from_clean(path: clean::Path, renderer: &JsonRenderer<'_>) -> Path {
|
||||
Path {
|
||||
name: path.whole_name(),
|
||||
name: path.last_opt().map_or(String::from(""), |s| String::from(s.as_str())),
|
||||
id: renderer.id_from_item_default(path.def_id().into()),
|
||||
args: path.segments.last().map(|args| Box::new(args.clone().args.into_json(renderer))),
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
/// This integer is incremented with every breaking change to the API,
|
||||
/// and is returned along with the JSON blob as [`Crate::format_version`].
|
||||
/// Consuming code should assert that this value matches the format version(s) that it supports.
|
||||
pub const FORMAT_VERSION: u32 = 37;
|
||||
pub const FORMAT_VERSION: u32 = 38;
|
||||
|
||||
/// The root of the emitted JSON blob.
|
||||
///
|
||||
|
||||
@@ -6,7 +6,7 @@ mod secret {
|
||||
}
|
||||
|
||||
//@ has "$.index[*][?(@.name=='get_secret')].inner.function"
|
||||
//@ is "$.index[*][?(@.name=='get_secret')].inner.function.sig.output.resolved_path.name" \"secret::Secret\"
|
||||
//@ is "$.index[*][?(@.name=='get_secret')].inner.function.sig.output.resolved_path.name" \"Secret\"
|
||||
pub fn get_secret() -> secret::Secret {
|
||||
secret::Secret
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user