Skip to content

Clarify and rename CrateItem #34

Open
@celinval

Description

@celinval

I was trying to write a test that would traverse the body of every function in a crate, but I couldn't do that by only using StableMIR APIs.

Not every CrateItem is a function, and there is no method to retrieve information about the type of CrateItem, so users can't tell whether it's valid to retrieve the item body. If a user tries to get the body of a non-function, StableMIR crashes. Note that just knowing that an item is a function will likely not be enough, since there are cases where the function body might not be available.

Besides providing more information about a CrateItem, we could also change the body of CrateItem::body to return Result<> instead.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions