Skip to content

Fix cast-related ICEs #24158

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 4 commits into from
Apr 9, 2015
Merged

Fix cast-related ICEs #24158

merged 4 commits into from
Apr 9, 2015

Conversation

sanxiyn
Copy link
Member

@sanxiyn sanxiyn commented Apr 7, 2015

Fix #13993.
Fix #17167.

@rust-highfive
Copy link
Contributor

r? @Aatch

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

@alexcrichton
Copy link
Member

cc @nrc

@nrc nrc assigned nrc and unassigned Aatch Apr 7, 2015
@nrc
Copy link
Member

nrc commented Apr 7, 2015

lgtm, r=me with the comments addressed

@sanxiyn
Copy link
Member Author

sanxiyn commented Apr 8, 2015

Addressed review comments.

@arielb1
Copy link
Contributor

arielb1 commented Apr 8, 2015

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
Copy link
Contributor

arielb1 commented Apr 8, 2015

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
Copy link
Member

nrc commented Apr 8, 2015

@bors r+ e2ff188

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

bors commented Apr 9, 2015

⌛ Testing commit e2ff188 with merge 287a544...

@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