Skip to content

[MIR] Implement as casting (Misc cast kind) #30586

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

Merged
merged 1 commit into from
Dec 31, 2015
Merged

Conversation

nagisa
Copy link
Member

@nagisa nagisa commented Dec 28, 2015

I think that should pretty much conclude all of #29576.

@rust-highfive
Copy link
Contributor

r? @Aatch

(rust_highfive has picked a reviewer for you, use r? to override)

@nagisa
Copy link
Member Author

nagisa commented Dec 28, 2015

r? @arielb1

@rust-highfive rust-highfive assigned arielb1 and unassigned Aatch Dec 28, 2015
&format!("unsupported cast: {:?} to {:?}", operand.ty, cast_ty)
)
};
OperandValue::Immediate(newval)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if assuming everything is immediate here is correct, but I can’t think of a case where it could be something else.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful of fat pointers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the cast cases written out above would handle or produce fat pointers. I’m more concerned with Ref vs Immediate. I.e. can Misc branch be reached with a OperandValue::Ref for castee.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The discriminant of an OperandValue is supposed to be a function of the operand's type.

@arielb1
Copy link
Contributor

arielb1 commented Dec 28, 2015

r+ if you add fat-pointer-to-thin-pointer and fat-pointer-to-fat-pointer casts.

@nagisa
Copy link
Member Author

nagisa commented Dec 29, 2015

I added preliminary impl of misc casts from fat-ptr, but I have little idea if it is correct. E.g. currently fat-ptr → fat-ptr is just a no-op, but only because I couldn’t think of a valid fat-ptr → fat-ptr cast which would change LLVM type of the fat-ptr.

EDIT: people on IRC helped me to find such a case which resulted in updated PR and discovery of an ICE.

@arielb1
Copy link
Contributor

arielb1 commented Dec 29, 2015

Ah well, I also want a test that identity casts work (e.g. Rc<Debug> -> Rc<Debug>). These should not be lowered to a cast at the MIR level, but that is not a reason for them not to compile.

@arielb1
Copy link
Contributor

arielb1 commented Dec 29, 2015

It's a separate bug.

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 29, 2015

📌 Commit feab2ae has been approved by arielb1

@bors
Copy link
Collaborator

bors commented Dec 31, 2015

⌛ Testing commit feab2ae with merge 19a351c...

bors added a commit that referenced this pull request Dec 31, 2015
I think that should pretty much conclude all of #29576.
@bors bors merged commit feab2ae into rust-lang:master Dec 31, 2015
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.

5 participants