-
Notifications
You must be signed in to change notification settings - Fork 179
Fix casting error behind generics #1938
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
Conversation
b1bb4fc
to
2afdec8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You found the right fix I think a small tweak to call restructure once would be ideal here. I also think this should be squashed into 1 commit.
Otherwise great job.
gcc/rust/typecheck/rust-casts.cc
Outdated
@@ -63,11 +63,11 @@ TypeCastRules::cast_rules () | |||
from.get_ty ()->debug_str ().c_str (), | |||
to.get_ty ()->debug_str ().c_str ()); | |||
|
|||
switch (from.get_ty ()->get_kind ()) | |||
switch (from.get_ty ()->destructure ()->get_kind ()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to do something like the unify code over in rust-unify.cc UnifyRules::go
TyTy::BaseType *
UnifyRules::go ()
{
TyTy::BaseType *ltype = lhs.get_ty ();
TyTy::BaseType *rtype = rhs.get_ty ();
ltype = lhs.get_ty ()->destructure ();
rtype = rhs.get_ty ()->destructure ();
So that you only need to call it once and it doesn't get lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edited it, please take another look.
Just so you know i would really like to merge this soon because I want to work on #1898 tomorrow |
If your having problems with the git commit format checker you can run the checker locally via:
|
4003c26
to
4be2d6c
Compare
gcc/rust/ChangeLog: * typecheck/rust-casts.cc (TypeCastRules::cast_rules): Perform destructure on `from` type. gcc/testsuite/ChangeLog: * rust/compile/cast_generics.rs: New test. Signed-off-by: Mahmoud Mohamed <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM good work
Fixes #1897
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog: