The following successfully typechecks on rustc 1.12.0-nightly (b30eff7ba 2016-08-05), but generates an LLVM assertion failure:
struct Node<T: ?Sized + Send> {
next: Option<Box<Node<Send>>>,
value: T,
}
fn clear(head: &mut Option<Box<Node<Send>>>) {
while let Some(node) = head.take() {
*head = node.next;
}
}
fn main() {}
Error:
rustc: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/Instructions.cpp:263: void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
Note that replacing *head = node.next with *head = node.next.take() (and making node mutable) allows compilation to succeed.
The following successfully typechecks on
rustc 1.12.0-nightly (b30eff7ba 2016-08-05), but generates an LLVM assertion failure:Error:
Note that replacing
*head = node.nextwith*head = node.next.take()(and makingnodemutable) allows compilation to succeed.