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

[MIR] Implement coercions and improve fat pointer support #29781

Merged
merged 6 commits into from
Nov 14, 2015

Conversation

arielb1
Copy link
Contributor

@arielb1 arielb1 commented Nov 11, 2015

I am also planning to implement casts, but I will probably do it in a separate PR.

r? @nikomatsakis

OperandValue::Imm(llval) => {
// ugly alloca.
debug!("trans_rvalue: creating ugly alloca");
let lltemp = base::alloc_ty(bcx, operand.ty, "__unsize_temp");
Copy link
Member

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?

Copy link
Contributor

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.

@nikomatsakis
Copy link
Contributor

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 Imm to Immediate. And of course if you feel the desire to write some more docs, that can't hurt too :), but I wouldn't block the PR on it.

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?

@arielb1
Copy link
Contributor Author

arielb1 commented Nov 12, 2015

@nikomatsakis

There is the fn_coercions test in mir_coercions, but I will add one for arrays too.

@arielb1
Copy link
Contributor Author

arielb1 commented Nov 12, 2015

⟨updated⟩

@bors
Copy link
Contributor

bors commented Nov 13, 2015

☔ 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
@arielb1
Copy link
Contributor Author

arielb1 commented Nov 13, 2015

⟨rebased⟩

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 13, 2015

📌 Commit b9b45a0 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Nov 14, 2015

⌛ Testing commit b9b45a0 with merge bdfb135...

bors added a commit that referenced this pull request Nov 14, 2015
I am also planning to implement casts, but I will probably do it in a separate PR.

r? @nikomatsakis
@bors bors merged commit b9b45a0 into rust-lang:master Nov 14, 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.

4 participants