-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[MIR] Implement coercions and improve fat pointer support #29781
Conversation
OperandValue::Imm(llval) => { | ||
// ugly alloca. | ||
debug!("trans_rvalue: creating ugly alloca"); | ||
let lltemp = base::alloc_ty(bcx, operand.ty, "__unsize_temp"); |
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.
Question out of curiosity: Is there any reason this should be alloca and cannot be regular LLVM temporary variable?
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.
@nagisa I think the reason is that base::coerce_unsized_into
expects its argument to be by-reference.
OK, so, this code looks good. r+ from me, but I left a few nits and things. Nothing major. The only thing I'd say let's definitely do is change the variant from One thing that might be nice is a few more tests. For example, I didn't see many tests where the MIR code actually does the unsizing, e.g.: #[rustc_mir]
fn foo(x: &[i32; 3]) -> &[i32] {
let y: &[i32] = x;
y
} Was that around, or did I miss it? |
There is the |
⟨updated⟩ |
☔ The latest upstream changes (presumably #29759) made this pull request unmergeable. Please resolve the merge conflicts. |
The implementation itself only requires changes to trans, but a few additional bugs concerning the handling of fat pointers had to be fixed.
this does add some complexity, but to do otherwise would require unsized lvalues to have their own allocas, which would be ugly.
no tests - sorry
⟨rebased⟩ |
@bors r+ |
📌 Commit b9b45a0 has been approved by |
I am also planning to implement casts, but I will probably do it in a separate PR. r? @nikomatsakis
I am also planning to implement casts, but I will probably do it in a separate PR.
r? @nikomatsakis