Skip to content

RA should use the toolchain's proc_macro instead of copying library/proc-macro. #12579

Closed
@eddyb

Description

@eddyb

I've brought this up elsewhere in the past, but it should've probably been a GH issue from the start. (I also regret not getting in touch with any RA devs when I heard they were working around the internal APIs of proc_macro, instead of with them - ideally we would streamline the aspects RA needs)

Right now, RA contains (slightly modified IIUC) copies of rust-lang/rust's library/proc-macro for various versions, and when the proc-macro ABI breaks on nightly, RA's proc macro support starts crashing.

However, this is far from the intended usage of the unstable proc_macro::bridge implementation details.

Instead, RA's proc macro support should be built against specific toolchains, and there's two scenarios:

  • RA build that supports multiple Rust versions
    • would have to embed sources (e.g. include_str!("proc-macro-srv/.../foo.rs")) to build on user's machine
    • to support stable, RUSTC_BOOTSTRAP=1 would need to be used (this is not IMO philosophically different from the second scenario, it's just that the build doesn't happen on rust-lang CI)
    • presumably this would be a binary that could be cached user-wide (when rustup is used, it could be cached in the toolchain itself, with the appropriate invalidation based on toolchain version etc.)
  • RA build shipped with rustup
    • this can be more strongly tied to the same Rust version it ships with (i.e. refuse working with mismatched Cargo/rustc)
    • can include the proc macro support in the build process, just like rustc does

For stable versions, pre-building the proc macro support in RA CI is also possible, but I don't see that scaling up to individual nightlies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-proc-macroproc macroC-ArchitectureBig architectural things which we need to figure up-front (or suggestions for rewrites :0) )C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions