-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
use std::mem;
struct Foo(Vec<u32>);
impl Drop for Foo {
fn drop(&mut self) {
if self.0.is_empty() {
return;
}
let v = mem::take(&mut self.0);
panic!("dead");
}
}
pub fn foo() {
let a = Foo(Vec::new());
unsafe {unknown(9);}
}
extern "Rust" {
fn unknown(x: i32) -> bool;
}https://rust.godbolt.org/z/ra7bj7zf1
Related issue: #114532. Notice that in this case drop is called before ret so this code can't be eliminated yet (I think).
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.