Skip to content

Experiment with a "(type) pattern pre-compiler" in rustc::ty::_match. #53735

@eddyb

Description

@eddyb

Instead of zipping two trees and using the same unification procedure as the rest of inference, the "pattern" type could be turned into linear "instruction stream" for a matcher ("interpreter"), to walk the type "tree", first to check that the type actually matches and then to unify variables (if any).

E.g for. Result<Vec<$0>, io::Error>, it would check the Result, Vec and io::Error heads, and for ($0, $0) it could equate the pair elements, before unifying a type with $0, in both cases.

This could also apply to Chalk, but I'm less familiar with its internal representation.
cc @nikomatsakis @sunjay

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions