#include "rust-abi.h"
#include "rust-compile-stmt.h"
#include "rust-compile-expr.h"
+#include "rust-compile-drop.h"
#include "rust-compile-fnparam.h"
#include "rust-compile-var-decl.h"
#include "rust-compile-type.h"
return_value = coercion_site (id, return_value, actual, expected,
lvalue_locus, rvalue_locus);
+ CompileDrop::emit_current_scope_drop_calls (ctx);
+
tree return_stmt
= Backend::return_statement (fndecl, return_value, locus);
ctx->add_statement (return_stmt);
// errors should have occurred
location_t locus = function_body.get_locus ();
tree return_value = unit_expression (locus);
+ CompileDrop::emit_current_scope_drop_calls (ctx);
tree return_stmt
= Backend::return_statement (fndecl, return_value, locus);
ctx->add_statement (return_stmt);
--- /dev/null
+// { dg-output "d\r*\n" }
+// { dg-additional-options "-w" }
+#![feature(no_core)]
+#![feature(lang_items)]
+#![no_core]
+
+extern "C" {
+ fn printf(s: *const i8, ...);
+}
+
+#[lang = "sized"]
+pub trait Sized {}
+
+#[lang = "drop"]
+pub trait Drop {
+ fn drop(&mut self);
+}
+
+struct Droppable;
+
+impl Drop for Droppable {
+ fn drop(&mut self) {
+ let msg = "d\n\0" as *const str as *const i8;
+ unsafe {
+ printf(msg);
+ }
+ }
+}
+
+fn f() {
+ let _x = Droppable;
+}
+
+fn main() -> i32 {
+ f();
+ 0
+}
--- /dev/null
+// { dg-output "d\r*\n" }
+// { dg-additional-options "-w" }
+#![feature(no_core)]
+#![feature(lang_items)]
+#![no_core]
+
+extern "C" {
+ fn printf(s: *const i8, ...);
+}
+
+#[lang = "sized"]
+pub trait Sized {}
+
+#[lang = "drop"]
+pub trait Drop {
+ fn drop(&mut self);
+}
+
+struct Droppable;
+
+impl Drop for Droppable {
+ fn drop(&mut self) {
+ let msg = "d\n\0" as *const str as *const i8;
+ unsafe {
+ printf(msg);
+ }
+ }
+}
+
+fn main() -> i32 {
+ let _x = Droppable;
+ 0
+}