Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an API to check if a Ty implements a trait #67

Open
momvart opened this issue Mar 2, 2024 · 1 comment
Open

Add an API to check if a Ty implements a trait #67

momvart opened this issue Mar 2, 2024 · 1 comment

Comments

@momvart
Copy link

momvart commented Mar 2, 2024

It can be handy to have an API that checks if a type implements a trait to not. Basic use cases include checking if the type implements some of the language-built-in marker traits like Copy.
The API can be added to Ty as follows.

fn implements(&self, def: TraitDef, generics: GenericArgs, param_env: ???) -> bool;
@momvart
Copy link
Author

momvart commented Mar 2, 2024

I think the implementation is straightforward using InferCtxt and type_implements_trait.

Anyway, I'm not sure how parameter environments are currently handled in smir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant