Closed
Description
The following code:
struct S;
impl S {
fn foo(&self) {
let _ = move || { self };
}
}
fn main() {
}
Triggers an assertion in LLVM:
crash.rs:1:1: 1:10 warning: struct is never used: `S`, #[warn(dead_code)] on by default
crash.rs:1 struct S;
^~~~~~~~~
crash.rs:4:5: 6:6 warning: method is never used: `foo`, #[warn(dead_code)] on by default
crash.rs:4 fn foo(&self) {
crash.rs:5 let _ = move || { self };
crash.rs:6 }
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/llvm/lib/IR/Instructions.cpp:1086: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed.
I get a slight variation if I change the code in the closure to call a member function instead:
struct S;
impl S {
fn foo(&self) {
let _ = move || { self.foo() };
}
}
fn main() {
}
Gives:
crash.rs:1:1: 1:10 warning: struct is never used: `S`, #[warn(dead_code)] on by default
crash.rs:1 struct S;
^~~~~~~~~
crash.rs:4:5: 6:6 warning: method is never used: `foo`, #[warn(dead_code)] on by default
crash.rs:4 fn foo(&self) {
crash.rs:5 let _ = move || { self.foo() };
crash.rs:6 }
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/llvm/lib/IR/Instructions.cpp:2522: static llvm::CastInst* llvm::CastInst::CreatePointerCast(llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::Instruction*): Assertion `S->getType()->isPtrOrPtrVectorTy() && "Invalid cast"' failed.