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

Compiler unexpectedly panicked at Box<Any> (built 2015-03-02) #23024

Closed
yann-ledu opened this issue Mar 4, 2015 · 2 comments
Closed

Compiler unexpectedly panicked at Box<Any> (built 2015-03-02) #23024

yann-ledu opened this issue Mar 4, 2015 · 2 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@yann-ledu
Copy link

#![feature(box_syntax)]
use std::any::Any;

fn main()
{
    fn h(x:i32) -> i32 {3*x}
    let mut vfnfer:Vec<Box<Any>> = vec![];
    vfnfer.push(box h);
    println!("{:?}",(vfnfer[0] as Fn)(3)); 
}
@oli-obk
Copy link
Contributor

oli-obk commented Mar 4, 2015

smaller example

fn main()
{
    fn h(x:i32) -> i32 {3*x}
    let vfnfer = vec![&h];
    let f = vfnfer[0] as Fn;
}

yields

<anon>:5:26: 5:28 error: angle-bracket notation is not stable when used with the `Fn` family of traits, use parentheses [E0215]
<anon>:5     let f = vfnfer[0] as Fn;
                                  ^~
<anon>:5:26: 5:28 help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
<anon>:5     let f = vfnfer[0] as Fn;
                                  ^~
<anon>:5:26: 5:28 error: wrong number of type arguments: expected 1, found 0 [E0243]
<anon>:5     let f = vfnfer[0] as Fn;
                                  ^~
<anon>:5:13: 5:22 error: internal compiler error: expected object type
<anon>:5     let f = vfnfer[0] as Fn;
                     ^~~~~~~~~

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 4, 2015
@frewsxcv
Copy link
Member

The original codeblock either needs to be updated to compile with the latest beta, or this is no longer causing an ICE.

~/Downloads $ rustc test.rs
test.rs:11:35: 11:37 error: angle-bracket notation is not stable when used with the `Fn` family of traits, use parentheses [E0215]
test.rs:11     println!("{:?}",(vfnfer[0] as Fn)(3));
                                             ^~
note: in expansion of format_args!
<std macros>:2:25: 2:56 note: expansion site
<std macros>:1:1: 2:62 note: in expansion of print!
<std macros>:3:1: 3:54 note: expansion site
<std macros>:1:1: 3:58 note: in expansion of println!
test.rs:11:5: 11:43 note: expansion site
test.rs:11:35: 11:37 help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
test.rs:11:35: 11:37 error: wrong number of type arguments: expected 1, found 0 [E0243]
test.rs:11     println!("{:?}",(vfnfer[0] as Fn)(3));
                                             ^~
note: in expansion of format_args!
<std macros>:2:25: 2:56 note: expansion site
<std macros>:1:1: 2:62 note: in expansion of print!
<std macros>:3:1: 3:54 note: expansion site
<std macros>:1:1: 3:58 note: in expansion of println!
test.rs:11:5: 11:43 note: expansion site
test.rs:11:35: 11:37 error: the value of the associated type `Output` (from the trait `core::ops::FnOnce`) must be specified [E0191]
test.rs:11     println!("{:?}",(vfnfer[0] as Fn)(3));
                                             ^~
note: in expansion of format_args!
<std macros>:2:25: 2:56 note: expansion site
<std macros>:1:1: 2:62 note: in expansion of print!
<std macros>:3:1: 3:54 note: expansion site
<std macros>:1:1: 3:58 note: in expansion of println!
test.rs:11:5: 11:43 note: expansion site
test.rs:11:22: 11:37 error: illegal cast; cast from fat pointer: `Box<core::any::Any>` as `core::ops::Fn<[type error]>`
test.rs:11     println!("{:?}",(vfnfer[0] as Fn)(3));
                                ^~~~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:25: 2:56 note: expansion site
<std macros>:1:1: 2:62 note: in expansion of print!
<std macros>:3:1: 3:54 note: expansion site
<std macros>:1:1: 3:58 note: in expansion of println!
test.rs:11:5: 11:43 note: expansion site
error: aborting due to 4 previous errors
~/Downloads $ rustc test.rs
test.rs:9:35: 9:37 error: angle-bracket notation is not stable when used with the `Fn` family of traits, use parentheses [E0215]
test.rs:9     println!("{:?}",(vfnfer[0] as Fn)(3));
                                            ^~
note: in expansion of format_args!
<std macros>:2:25: 2:56 note: expansion site
<std macros>:1:1: 2:62 note: in expansion of print!
<std macros>:3:1: 3:54 note: expansion site
<std macros>:1:1: 3:58 note: in expansion of println!
test.rs:9:5: 9:43 note: expansion site
test.rs:9:35: 9:37 help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
test.rs:9:35: 9:37 error: wrong number of type arguments: expected 1, found 0 [E0243]
test.rs:9     println!("{:?}",(vfnfer[0] as Fn)(3));
                                            ^~
note: in expansion of format_args!
<std macros>:2:25: 2:56 note: expansion site
<std macros>:1:1: 2:62 note: in expansion of print!
<std macros>:3:1: 3:54 note: expansion site
<std macros>:1:1: 3:58 note: in expansion of println!
test.rs:9:5: 9:43 note: expansion site
test.rs:9:35: 9:37 error: the value of the associated type `Output` (from the trait `core::ops::FnOnce`) must be specified [E0191]
test.rs:9     println!("{:?}",(vfnfer[0] as Fn)(3));
                                            ^~
note: in expansion of format_args!
<std macros>:2:25: 2:56 note: expansion site
<std macros>:1:1: 2:62 note: in expansion of print!
<std macros>:3:1: 3:54 note: expansion site
<std macros>:1:1: 3:58 note: in expansion of println!
test.rs:9:5: 9:43 note: expansion site
test.rs:9:22: 9:37 error: illegal cast; cast from fat pointer: `Box<core::any::Any>` as `core::ops::Fn<[type error]>`
test.rs:9     println!("{:?}",(vfnfer[0] as Fn)(3));
                               ^~~~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:25: 2:56 note: expansion site
<std macros>:1:1: 2:62 note: in expansion of print!
<std macros>:3:1: 3:54 note: expansion site
<std macros>:1:1: 3:58 note: in expansion of println!
test.rs:9:5: 9:43 note: expansion site
error: aborting due to 4 previous errors
~/Downloads $ rustc --version
rustc 1.0.0-beta.2 (e9080ec39 2015-04-16) (built 2015-04-16)

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 25, 2015
bors added a commit that referenced this issue Sep 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants