Skip to content

Tool for checking the safety of non-exhaustive patterns #2896

Closed
@catamorphism

Description

@catamorphism

This is definitely in the department of blue-sky, out-there projects, but I was just thinking about option::get and wondering how feasible it would be to adapt the ideas in Neil Mitchell's Catch tool (for Haskell) to Rust.

http://community.haskell.org/~ndm/catch/

In our case, this would be to verify that alt check, and maybe even functions that pattern-match on their input and unconditionally fail in one or more branches (like option::get) are being used safely (which is to say, in a way that won't cause a runtime failure). This would be one way to allow alt checks and get a safety guarantee.

Mutability would definitely complicate things, but one way out is to only provide any guarantees about immutable data (and warn in a lint pass about alt check and similar things on mutable data).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)A-type-systemArea: Type systemE-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions