Skip to content

Architectural groundwork for expansion-time evaluation #620

Open

Description

@tomassedovic
Metadata
Contact @oli-obk
Team(s) compiler (@petrochenkov), types (@oli-obk)
Goal document 2026/expansion-time-evaluation
Funding contact RustNL

Summary

Lay the architectural groundwork for functions that can be evaluated during macro expansion. This speculative work focuses on "queryifying" the resolver and implementing a restricted trait solver mode, enabling future language features like macro fn and compiler-integrated interop tools.


This issue is intended for status updates only.

For general questions or comments, please contact a goal owner or post in the Zulip topic.

Activity

  1. added this to the 2026 milestone on May 5, 2026
  2. tomassedovic commented on May 5, 2026

    @tomassedovic
    ContributorAuthor

    This issue is intended for status updates only.

    For general questions or comments, please contact the owner(s) directly.

  3. added 2 commits that reference this issue on May 13, 2026
  4. assigned and unassigned on Jun 3, 2026
  5. oli-obk commented on Jun 3, 2026

    @oli-obk
    Contributor

    First update:

    I did the groundwork refactorings for avoiding node_id_to_def_id splitting into a per-owner table being a perf regression. Not only did that succeed, but it turned out to be a (small) performance improvement to do those refactorings.

    The refactorings in question:

    After those, the split PR was perf neutral

    Which was than fairly easy to follow up with

    which leaves the remaining fields

    • partial_res_map
    • extra_lifetime_params_map
    • lint_buffer (probably easy)
    • delegation_infos
    • disambiguators (easy, but may be perf-relevant, we'll see)

    extra_lifetime_params_map is somewhat blocked on rust-lang/rust#156508 to finish splitting the resolver's owner-relevant maps into per-owner ones, but once crater finishes on that I'm going to start a T-types FCP. In parallel I can still work on the follow-ups, but probably can't land them due to perf reasons, will try. But def will work on the other fields in parallel

  6. oli-obk commented on Jul 8, 2026

    @oli-obk
    Contributor

    Not too much directly for this goal, although in parallel I have been pursuing groundwork to unlock making the delegation HIR queries have cycle errors if they are cyclic instead of requiring an extra cycle detection pass that needs more global information

    The most important change is

    which splits the hir_crate query into per-owner queries. While on its own it doesn't allow for any incremental improvements, we can now lower the HIR of individual owners without having to have all other owners also lowered. In theory now the lowering of one HIR owner can depend on anothers' HIR

  7. added a commit that references this issue on Jul 16, 2026
  8. added 2 commits that reference this issue on Jul 16, 2026
  9. oli-obk commented on Sep 10, 2026

    @oli-obk
    Contributor

    I ran into some warts that made it hard to finish the split of resolver data for ast lowering. The remaining issues all related to use statements, so I am attempting to keep use statements in their tree form (that they have in AST), so that the HIR doesn't have to change anything about that. This has some complications, too, but it is generally a cleanup and allows for further cleanups down the road: rust-lang/rust#161349

    I'm now also working on adding a new trait solver mode that allows us to run the trait solver (and thus also some things depending on it) without triggering ast lowering. This works by restricting the trait solver in that mode to only look at things from upstream crates and ignore all impls from this crate.

  10. added a commit that references this issue on Sep 24, 2026
  11. oli-obk commented on Oct 9, 2026

    @oli-obk
    Contributor

    In a local branch I now have basic trait solving working from within a builtin macro. You can use it to check if a type from an upstream crate implements a trait from an upstream crate (including specifying different generic parameters for the trait (e.g. bool: PartialEq<bool> vs bool: PartialEq<u32>)

    I'm now working on a small demo showing what you can do with it in practice.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions