Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portable rustc Exports #41

Merged
merged 4 commits into from
Sep 17, 2023
Merged

Portable rustc Exports #41

merged 4 commits into from
Sep 17, 2023

Conversation

JustusAdam
Copy link
Collaborator

What Changed?

Introduces the rustc_portable module that exports either rustc identifiers (like DefId) or our proxy. Together with cfg_attr this makes it more ergonomic to define data structures that are used outside of rustc but depend on those identifiers.

Why Does It Need To?

I really didn't like the

struct Foo {
    #[cfg(feature = "rustc")]
    #[serde(with = "rustc_proxies::DefId")]
    def_id: def_id:: DefId,
    #[cfg(not(feature = "rustc"))]
    def_id: rustc_proxies::DefId,
}

code blocks. I think they are hard to read and easy to get wrong. Now you can write

struct Foo {
    #[cfg_attr(feature = "rustc", serde(with = "rustc_proxies::DefId"))]
    def_id: rustc_portable:: DefId,
}

Checklist

  • Above description has been filled out so that upon quash merge we have a
    good record of what changed.
  • New functions, methods, types are documented. Old documentation is updated
    if necessary
  • Documentation in Notion has been updated
  • Tests for new behaviors are provided
    Works if it compiles 😄
    • New test suites (if any) ave been added to the CI tests (in
      .github/workflows/rust.yml) either as compiler test or integration test.
      Or justification for their omission from CI has been provided in this PR
      description.

@JustusAdam JustusAdam merged commit 2c55d1e into main Sep 17, 2023
@JustusAdam JustusAdam deleted the portable-exports branch September 17, 2023 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant