Alona Enraght-Moony
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Rustdoc JSON Cross-Crate `Id` resolution NOTE: Right now, these notes are mainly targetted at me, and assume you have context. These were 50% dumping from my brain, and 50% meeting notes from the all hands. ## Big Non-contirverial things - Add `version` to `rustdoc_json_types::ExternCrate` - Turns out we don't have the information to do this I think. - Add rustdoc output paths to `cargo --message-format=json` - <https://github.com/rust-lang/cargo/issues/15558> ## Problem > This need's it's own issue at some point, but for [the zulip chat](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Rustdoc.20JSON.3A.20Include.20All.20Foreign.20Items.3F) is the best resource. > > The problem we want to solve is that if I have an `Id` from one crate's json, but the Id is for a foreign type, then it won't be present in `index`, only `paths`. If you want to see the `Item`, you need to find the json for the crate that this `Id` is from. The problem is that in this JSON you need to use a different ID. To find the ID in the crate the item is local to, you need to find the path for the item from `paths`, and then look that up the the json for the crate the item's from. > > This is cumbersome, slow, and unreliable [^unreliable]. > > Idealy you should be able to just use the Id from one JSON in another. I'm not sure if this is possible, or if we'll need some translation scheme, potentially spiting Id's into two fields (crate id, and item id). How exactly this will work needs further design work. [^unreliable]: Especialy when the `path` isn't present in the public docs. -- [Rustdoc-JSON 2023 roadmap](https://github.com/rust-lang/rust/issues/106697), ~~which still isn't implemented lol~~ ## Solution - `Id` should be split into 2 parts, crate id & item id - Resolve crate id to find json document with info - Needs cargo cooperation to deal with versions. CC `--orchestator-id` - Alternative option from Urgau, map crate id -> rlib - Then callers zip this information with cargo json output to find exact details of crate that gave that rlib. - `cargo build --message-format json` prints enough info I think, has paths to `.rmeta` for crates that arn't built. - Can use the full `"package_id"` from this output: `cargo +nightly rustdoc -p registry+https://github.com/rust-lang/crates.io-index#libc@0.2.172 --output-format json -Z unstable-options - Cargo people think that the rmeta path is stable enough to be the same, - `-C extra-filename` is the hash used for the rmeta path. - https://doc.rust-lang.org/nightly/nightly-rustc/cargo/core/compiler/fingerprint/index.html - `-C metadata` isn't the same as `-C extra-fielename` anymore: see https://doc.rust-lang.org/nightly/nightly-rustc/cargo/core/compiler/fingerprint/index.html - Can cargo ever map from a metadata/extra-filename back to something more usefull? - Maybe?? But it'd be a heuristic, and this shouldn't be in cargo cli's. - You need to run build-scripts to get a build graph, to get this stuff. - Also, it might not exist anymore in the current build graph, but it could exist in the target dir. - A question: Can we use package-id in rustdoc-json output: - NO: package-id uniquely identifies a package, but not a unit in a build-graph: https://doc.rust-lang.org/cargo/reference/pkgid-spec.html - Also: requires invasive changes to rustc. - Alternative from jyn: Use `-C metadata` - Problem: cargo passes different `-C metadata` to rustc and check in json - Not sure why? Jacob Finkelman thinks it's a reasonable - https://github.com/rust-lang/cargo/blob/47c911e9e6f6461f90ce19142031fe16876a3b95/src/cargo/core/compiler/build_runner/compilation_files.rs#L615 - Needs a plumbing command to map metadata -> packageid - Or build everything with `(package, version)`, then iterate and find document with that metadata hash. - Can rustdoc emit metadata as well as build stuff. - Might be good in general - This way, you build your docs for deps at the same time as you build their metadata for leaf crate. - Falls over due to `cfg(doc)` - Lookup idem id in the `$.index` of the json document for that crate - Needs rustc cooperation to know what that ID will be. - We can't """just""" use `DefId`/`HirId` becuase rustdoc-json gives more things ID's than they do: https://github.com/rust-lang/rust/blob/master/src/librustdoc/json/ids.rs From Predrag: CSC already does the nameres, so only solving the crate resolution problem is still super usefull for them. Another thaught: However we link CCI for HTML should also work for json! - NOPE: The HTML way it at the moment is kinda sad, mangles links between `time@1` and `time@2` - Cargo doesn't have a way to determine set of features of a depenceny yet. - Maybe "manifest v2 metadata plumbing" will solve this. - GSOC student working on it. ## Docs.rs stuff - We should add stuff to `ExternCrate`: - Version - Can't know this stuff well :'( - Provide both package name and crate name - Rustdoc has to know this, for html_root_url - Need to pass `-Zrustdoc-map` when running `cargo rustdoc` - Memory usage: Can we borrow string from the input? ## Other stuff from rustdoc <-> cargo - Cargo wants a `.d` file from rustdoc, and maybe some more things so they rebuild correctly. Talk to Jacob Finkelman about it. - Also `--emit=filenames` - Apparently this exists, guiomme and epage working on it! - https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#rustdoc-depinfo - Cargo should use https://rust-lang.github.io/rfcs/3662-mergeable-rustdoc-cross-crate-info.html - Fuschia might have a patch to cargo. - Rustdoc should add `-C metadata` to rustdoc file name - Cargo `--message-format=json` should print the output json path with `-w json` - Also maybe needs `--emit=filenames` - If cbor becomes a thing across project, rustdoc-json ## Other random perf stuff - Bincode output for rustdoc-json - Put rustdoc-json in rustc perf. ## Issues/Links - [`--orchestrator-id` MCP](https://github.com/rust-lang/compiler-team/issues/635) - Possibly a bad idea says Urgau - Adds a new tracked input to rustc, will change crate hashes - [[rustdoc-json] `paths` is inconsistent and questionably useful](https://github.com/rust-lang/rust/issues/93522) - [[rustdoc-json] Partially remove `paths` and introduce `external_index`](https://github.com/rust-lang/rust/pull/103085) - [Rustdoc-Json: some item IDs are missing in `paths` field.](https://github.com/rust-lang/rust/issues/101687) - [[rustdoc-json] absolute position of item is hard to get](https://github.com/rust-lang/rust/issues/93524)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully