Skip to content

Convert check functions to judgment functions #288

@nikomatsakis

Description

@nikomatsakis

Tracking issue for converting the top-level checking code from regular Rust functions (that manually construct proof trees) into judgment functions.

How it works today

a-mir-formality begins today by calling check_all_crates. This in turn checks every combination of crates (they are expected to appear in dependency order) with check_crate, which calls check_crate_item, which dispatches on CrateItem variants.

Each of these Rust functions returns an Fallible<T> which is a type alias for anyhow::Result. They manually construct proof trees in the case of a successful run. They are written in a functional style that avoids mutating data that is not local to the function.

How we want it to work

We want to move away from Rust functions towards judgment functions. This is a great issue to practice writing judgment functions. Using a judgment function means that we'll automatically construct proof trees via the macro, but it also means we'll have better support for instrumentation, coverage checking, reference text generation, and other things we plan to do in the future.

See the formality-core book for documentation on how judgment functions work.

Example: check_crate_item

As a simple example, see PR #287 which converted some of the "top-level Rust functions" into judgments.

How to help out

Find a subissue that is not claimed.

Add a comment @rustbot claim.

To leave room for others, please just claim one sub-issue so others can pick up the rest.

Things we don't need to convert

These functions can stay as Rust, they're more like little helper functions or tests or plumbing. You may wish to extract similar helper functions in some cases.

  • check_for_duplicate_items / check_trait_items_have_unique_names — structural validation, not proof logic
  • merge_binders — utility
  • prove_goal / prove_judgment / prove_not_goal — wrappers around judgment functions
  • prove_where_clauses_well_formed — thin wrapper

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    metaA tracking issue (an issue about issues)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions