Skip to content

Dash (-) in a crate name breaks rustdoc-scrape-examples #10035

Closed
@WaffleLapkin

Description

@WaffleLapkin

Problem

When a crate has a dash (-) in its name, the unstable rustdoc-scrape-examples option stops working.

Steps

  1. Create a crate with a dash in it's name: cargo new --lib da-sh && cd da-sh
  2. Add a function to the crate: echo "pub fn f() {}" >> src/lib.rs
  3. Add an example that uses the added function: mkdir examples && echo "fn main() { da_sh::f() }" > examples/e.rs
  4. Run rustdoc: cargo +nightly doc -Zunstable-options -Zrustdoc-scrape-examples=examples --open
  5. Observe documentation of f (example is missing): image
  6. Remove dash from the crate name: sed -i 's/da-sh/dash/' Cargo.toml && sed -i 's/da_sh/dash/' examples/e.rs
  7. Run rustdoc: cargo +nightly doc -Zunstable-options -Zrustdoc-scrape-examples=examples --open
  8. Observe documentation of f (example is present): image

Possible Solution(s)

No response

Notes

I'm not sure if this is an issue with rustdoc or cargo, maybe this issue should be moved to rustdoc repo.

Version

cargo 1.58.0-nightly (94ca096af 2021-10-29)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions