Closed
Description
The compiler never checks that the language item it receives is of the correct type or signature. This leads to craziness like:
#[no_std];
#[main]
#[lang="start"]
fn start() { }
[2:21:07]/tmp> rustc foo.rs
task 'rustc' has overflowed its stack
zsh: illegal hardware instruction (core dumped) rustc foo.rs
or, more benignly:
#[no_std];
#[lang="start"]
fn start() { }
#[main]
fn main() { }
which just plain asserts:
rustc: /build/rust-git/src/rust/src/llvm/lib/IR/Instructions.cpp:276: void llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&): Assertion `(Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!"' failed.
or, more crazily:
#[no_std];
#[lang="start"]
mod a { }
#[main]
fn main() { }
which "just" ICEs:
error: internal compiler error: node_id_to_type: no type for node `mod a (id=2)`
This message reflects a bug in the Rust compiler.
We would appreciate a bug report: https://github.com/mozilla/rust/wiki/HOWTO-submit-a-Rust-bug-report
task 'rustc' failed at 'explicit failure', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:102
task '<main>' failed at 'explicit failure', /build/rust-git/src/rust/src/librustc/lib.rs:395
Language items are the interface between the compiler and the language. They need to be well-defined and verified for correctness.