Skip to content

Allow crates downstream of rustc_middle to define queries #966

@Zoxc

Description

@Zoxc

Proposal

This proposes allowing crates downstream of rustc_middle to define their own queries. The crates defining queries still have to be upstream from rustc_interface.

This is useful as we can then define queries on types unavailable in rustc_middle or move types currently forced to be in rustc_middle to an appropriate location.

Crates will have a queries module listing queries, which uses macros to defined needed code like the current rustc_middle::queries.

Accessing queries will be done with an extension trait, so to use rustc_borrowck's queries you'd import rustc_borrowck::Queries, then you'd be able to call them on tcx.

Each crate defining queries will need their own state for the query system to use, so GlobalCtxt will have a rustc_borrowck: &'tcx dyn Any<'tcx> field per such crate (with some unsafe to make 'tcx work). That allows access to that state from TyCtxt. The state can be owned by rustc_interface.

Mentors or Reviewers

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member who is knowledgeable in the area can second by writing @rustbot second or kickoff a team FCP with @rfcbot fcp $RESOLUTION.
  • Once an MCP is seconded, the Final Comment Period begins.
    • Final Comment Period lasts for 10 days after all outstanding concerns are solved.
    • Outstanding concerns will block the Final Comment Period from finishing. Once all concerns are resolved, the 10 day countdown is restarted.
    • If no concerns are raised after 10 days since the resolution of the last outstanding concern, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Caution

Concerns (2 active)

Managed by @rustbot—see help for details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerAdd this label so rfcbot knows to poll the compiler teamhas-concernsThere are active concernsmajor-changeA proposal to make a major change to rustc

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions