-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ICE: translating unsupported cast #24100
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
Comments
Me too: Crate: https://github.com/goertzenator/liblrust Output: https://gist.github.com/goertzenator/912f010da6f2ae243336 Rust:
OS:
|
Me three, with this trivial program: #[derive(Debug)]
struct S {
v: String,
}
fn main() {
let x = S { v: "hello".to_string() };
println!("{:?}", x as S);
}
Self-built rustc from the 1.0.0-beta commit:
|
Adding another report, with a similar setup. Encountered this in my code, boiled it down to this test...looks very similar to @robn's ICE, since it is trying to cast "same" -> "same". Seems to only happen when trying to cast a struct to itself with
pub struct Consumer<T> {
vec: Vec<T>
}
impl<T> Consumer<T> {
pub fn pop(&mut self) -> T {
self.vec.pop().unwrap() as T // <--- Removing "as T" fixes the ICE
}
}
// #[derive(Copy, Clone)] // <-- tried to add Copy/Clone, does not fix ICE
struct TestStruct {
a: u32
}
impl TestStruct {
pub fn new() -> TestStruct {
TestStruct { a: 19 }
}
}
#[test]
fn test_struct() {
let mut c = Consumer {
vec: vec![TestStruct::new(), TestStruct::new()]
//vec: vec![0,1,2,3] // <-- works fine
};
let t: TestStruct = c.pop();
} |
Fixes ICEs where non-fat pointers and scalars are cast to fat pointers, Fixes rust-lang#21397 Fixes rust-lang#22955 Fixes rust-lang#23237 Fixes rust-lang#24100
Example code:
Error message:
Rust:
OS:
The text was updated successfully, but these errors were encountered: