Skip to content

Fix cast-related ICEs#24158

Merged
bors merged 4 commits into
rust-lang:masterfrom
sanxiyn:cast
Apr 9, 2015
Merged

Fix cast-related ICEs#24158
bors merged 4 commits into
rust-lang:masterfrom
sanxiyn:cast

Conversation

@sanxiyn

@sanxiyn sanxiyn commented Apr 7, 2015

Copy link
Copy Markdown
Contributor

Fix #13993.
Fix #17167.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @Aatch

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

@alexcrichton

Copy link
Copy Markdown
Member

cc @nrc

@nrc nrc assigned nrc and unassigned Aatch Apr 7, 2015
@nrc

nrc commented Apr 7, 2015

Copy link
Copy Markdown
Member

lgtm, r=me with the comments addressed

@sanxiyn

sanxiyn commented Apr 8, 2015

Copy link
Copy Markdown
Contributor Author

Addressed review comments.

@arielb1

arielb1 commented Apr 8, 2015

Copy link
Copy Markdown
Contributor

I would also add a test for cast from a ?Sized type parameter:

fn nullptr<T: ?Sized>() -> *const T {
    0 as *const _
}
fn main() {
    nullptr::<[();3]>();
    nullptr::<[()]>();
}

Also, &_ as usize is a non-scalar cast anyway.

@arielb1

arielb1 commented Apr 8, 2015

Copy link
Copy Markdown
Contributor

There are more interesting cases:

use std::fmt;
use std::iter::IntoIterator;

fn ptr_cast<U: ?Sized, V: ?Sized>(u: *const U) -> *const V
{
   u as *const _
}

fn main() {
    let i0 = [5u32];
    let i1 = i0.into_iter();
    let i2 : &Iterator<Item=&u32> = &i1;
    let i3 = i2 as *const Iterator<Item=&u32>;
    let p: *const fmt::Display = ptr_cast::<_, fmt::Display>(i3);
}

I guess this needs a separate issue.

@nrc

nrc commented Apr 8, 2015

Copy link
Copy Markdown
Member

@bors r+ e2ff188

bors added a commit that referenced this pull request Apr 9, 2015
@bors

bors commented Apr 9, 2015

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e2ff188 with merge 287a544...

@bors

bors commented Apr 9, 2015

Copy link
Copy Markdown
Collaborator

@bors bors merged commit e2ff188 into rust-lang:master Apr 9, 2015
@sanxiyn sanxiyn deleted the cast branch April 9, 2015 03:55
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.

ICE: translating unsupported cast (*const DST -> uint) ICE: Failure in unsupported-cast.rs

7 participants