Skip to content

rustc-dev component is broken by missing literal-escaper #138647

Closed

Description

@RalfJung

Trying to load the rustc-dev packages with cargo leads to an error:

    Updating crates.io index
error: failed to get `literal-escaper` as a dependency of package `rustc_ast v0.0.0 (/home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc_ast)`
    ... which satisfies path dependency `rustc_ast` of package `rustc_codegen_ssa v0.0.0 (/home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc_codegen_ssa)`
    ... which satisfies path dependency `rustc_codegen_ssa` of package `rustc-main v0.0.0 (/home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc)`

Caused by:
  failed to load source for dependency `literal-escaper`

Caused by:
  Unable to update /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/library/literal-escaper

Caused by:
  failed to read `/home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/library/literal-escaper/Cargo.toml`

Caused by:
  No such file or directory (os error 2)

This is caused by #136355: compiler crates cannot have path dependencies outside the compiler folder.

Cc @GuillaumeGomez @Amanieu

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 18, 2025
  2. GuillaumeGomez commented on Mar 18, 2025

    @GuillaumeGomez
    Member

    cc @rust-lang/bootstrap

  3. Kobzol commented on Mar 18, 2025

    @Kobzol
    Member

    Hmm, I'm not sure if we want to ship library sources in the rustc-dev rustup component (which contains only the compiler sources currently).

  4. Kobzol commented on Mar 18, 2025

    @Kobzol
    Member

    But I guess why not? Anyone have any concerns about doing that?

  5. bjorn3 commented on Mar 18, 2025

    @bjorn3
    Member

    It should also be possible to add just library/literal-escaper, right?

  6. Amanieu commented on Mar 18, 2025

    @Amanieu
    Member

    One possible solution:

    • rustc_lexer should not depend on literal-escaper via a Cargo.toml dependency, it should instead import it directly with extern crate literal_escaper to get the one from the library sysroot.
    • For cfg(bootstrap) where literal-escaper is not available in the library sysroot just use #[path] to include the code directly.
  7. Veykril commented on Mar 18, 2025

    @Veykril
    Member

    rustc_lexer should not depend on literal-escaper via a Cargo.toml dependency, it should instead import it directly with extern crate literal_escaper to get the one from the library sysroot.

    This will break rustc_lexer from compiling on stable I believe. Not that it matters I suppose as the change done here in general makes it impossible to publish the crate to crates-io now for rust-analyzer :/

  8. Kobzol commented on Mar 18, 2025

    @Kobzol
    Member

    It should also be possible to add just library/literal-escaper, right?

    Sure, we could selectively add only the required crates.

  9. bjorn3 commented on Mar 18, 2025

    @bjorn3
    Member

    Another option would be to publish literal-escaper to crates.io. That would also allow proc-macro2 to use it. proc-macro2 needs to support not using libproc_macro, so it can't unconditionally use literal escaping through libproc_macro.

  10. GuillaumeGomez commented on Mar 18, 2025

    @GuillaumeGomez
    Member

    Publishing on crates.io seems like the simplest solution. Should I do it?

  11. Kobzol commented on Mar 18, 2025

    @Kobzol
    Member

    That doesn't sound like the simplest solution to me, tbh 😅 Unless the code is done and will never ever change? Otherwise we should probably have some setup for deploying it, managing the crates.io token, figuring out who will own the crate etc. (it probably shouldn't be owned by your GH account).

  12. changed the title [-]rustc-src component is broken by missing literal-escaper[/-] [+]rustc-dev component is broken by missing literal-escaper[/+] on Mar 18, 2025
  13. GuillaumeGomez commented on Mar 18, 2025

    @GuillaumeGomez
    Member

    Very good point. Then I'll keep quiet in the back and step in if my help is needed. 😆

  14. RalfJung commented on Mar 18, 2025

    @RalfJung
    MemberAuthor

    the change done here in general makes it impossible to publish the crate to crates-io now for rust-analyzer :/

    So this change broke not just Miri but also RA?

    I've posted a revert to avoid blocking multiple tools while we figure out a proper solution: #138661.

  15. GuillaumeGomez commented on Mar 18, 2025

    @GuillaumeGomez
    Member

    Just a small thing if publishing to crates.io is a possibility: we have a crate in rustdoc (https://crates.io/crates/rustdoc-json) that is published with rights given to https://cargo-public-api. Isn't it possible to do the same here?

  16. 7 remaining items

  17. added a commit that references this issue on Mar 18, 2025
  18. GuillaumeGomez commented on Mar 18, 2025

    @GuillaumeGomez
    Member

    I created https://github.com/GuillaumeGomez/literal-escaper. So if we agree on publishing it to crates.io, we can move it to the rust-lang organization.

  19. RalfJung commented on Mar 18, 2025

    @RalfJung
    MemberAuthor

    Add library/literal-escaper to rustup components

    That also won't help for RA I think.

    crates.io is probably the only option for sharing a dependency between library and compiler.

  20. GuillaumeGomez commented on Mar 18, 2025

    @GuillaumeGomez
    Member

    Seems like crates.io it is. @Kobzol is gonna open a thread on zulip t-infra channel for the discussion to continue there.

  21. added a commit that references this issue on Mar 18, 2025
  22. added a commit that references this issue on Mar 19, 2025
  23. added a commit that references this issue on Mar 19, 2025
  24. added
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    on Mar 22, 2025
  25. added
    C-bugCategory: This is a bug.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 26, 2025
  26. added a commit that references this issue on Apr 2, 2025
  27. GuillaumeGomez commented on May 22, 2025

    @GuillaumeGomez
    Member

    literal-escaper is now published on crates.io and used in both rustc and proc-macro as dependency (since #139367).

    So this issue is now fixed. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dist-componentsArea: dist components, e.g. `rustc-dev`, `rustc-src`, etc.C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions