Description
I tried to create a generic extern fn, and accidentally left off the type parameter. That caused an ICE. This code reproduces it:
fn with_type_params<T>() { }
extern fn foo<T>() {
with_type_params::<T>();
}
fn main() {
let _a:*u8 = foo;
}
and produces this error from the compiler with RUST_LOG=rustc=1
:
task <unnamed> failed at 'assertion failed: !ty::type_has_params(*s)', /build/buildd/rust-nightly-201308162101~680eb71~raring/src/librustc/middle/trans/monomorphize.rs:78
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task <unnamed> failed at 'explicit failure', /build/buildd/rust-nightly-201308162101~680eb71~raring/src/librustc/rustc.rs:371
I wouldn't expect the code above to actually compile, since the type parameter is missing, but it should show an error about that rather than an ICE.
Trying to fix the problem--changing the bare foo
to foo::<int>
in main
, for instance--produced a normal compiler error: "this item does not take type parameters." That also seems wrong--if extern fns are not allowed to take type parameters, then shouldn't the compiler should complain about it at the definition? If they are allowed, then I should be able to take the address of one with the type parameter filled in. (Indeed, that should be required in order to use them.)