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 safe up/downcasting to the Rust object system #6384

Merged
merged 2 commits into from Sep 4, 2020

Conversation

mwillsey
Copy link
Contributor

@mwillsey mwillsey commented Sep 2, 2020

I took a clean up pass over the TVM object system in the Rust bindings. There are still some things to improve, but I think this is worth landing on its own.

The upshot is now any IsObjectRef has a safe, typechecked upcast method to anything it inherits from. downcast is also typechecked, in that you may only attempt a downcast to from T to U if U is a subclass of T. There are some other minor cleanups in the Object derive-macro as well.

@jroesch

rust/tvm-rt/src/object/object_ptr.rs Outdated Show resolved Hide resolved
rust/tvm-rt/src/object/object_ptr.rs Show resolved Hide resolved
rust/tvm-macros/src/object.rs Outdated Show resolved Hide resolved
@jroesch jroesch merged commit 73d9e01 into apache:master Sep 4, 2020
kevinthesun pushed a commit to kevinthesun/tvm that referenced this pull request Sep 17, 2020
* Revamp the rust object system with safe subtyping

* Small nits
kevinthesun pushed a commit to kevinthesun/tvm that referenced this pull request Sep 18, 2020
* Revamp the rust object system with safe subtyping

* Small nits
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Sep 18, 2020
* Revamp the rust object system with safe subtyping

* Small nits
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

Successfully merging this pull request may close these issues.

None yet

3 participants