From e92f02fd6426af8b01ed2c5ed5c4c77872bbae20 Mon Sep 17 00:00:00 2001 From: StunxFS Date: Mon, 1 Jan 2024 09:03:38 -0400 Subject: [PATCH] refactor(rivet): rename special method `__drop__` to `__destroy__` --- lib/core/src/DynArray.ri | 2 +- lib/core/src/string.c.ri | 2 +- lib/rivet/src/checker/decls.ri | 2 +- lib/std/src/dynlib/mod.c.ri | 2 +- tests/invalid/directly_call_a_special_method.out | 4 ++-- tests/invalid/directly_call_a_special_method.ri | 8 ++++---- tests/valid/src/special_methods.ri | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/core/src/DynArray.ri b/lib/core/src/DynArray.ri index 5049673ef..cc76d6739 100644 --- a/lib/core/src/DynArray.ri +++ b/lib/core/src/DynArray.ri @@ -209,7 +209,7 @@ struct DynArray { return dyn_array; } - func __drop__(self) { + func __destroy__(self) { unsafe { mem_dealloc(self.ptr); } diff --git a/lib/core/src/string.c.ri b/lib/core/src/string.c.ri index 977a504bb..62c613d7c 100644 --- a/lib/core/src/string.c.ri +++ b/lib/core/src/string.c.ri @@ -373,7 +373,7 @@ pub struct string < Stringable, Hashable, Throwable { return self > rhs || self == rhs; } - func __drop__(self) { + func __destroy__(self) { if !self.is_ref { unsafe { mem_dealloc(self.ptr); diff --git a/lib/rivet/src/checker/decls.ri b/lib/rivet/src/checker/decls.ri index e14104e97..5917f82d7 100644 --- a/lib/rivet/src/checker/decls.ri +++ b/lib/rivet/src/checker/decls.ri @@ -203,7 +203,7 @@ extend Checker { ); } match func_decl.name { - "__drop__" -> {}, + "__destroy__" -> {}, else -> report.error( "unknown special method `{}`".fmt(func_decl.name), func_decl.pos diff --git a/lib/std/src/dynlib/mod.c.ri b/lib/std/src/dynlib/mod.c.ri index 59ecc45a5..958fc5520 100644 --- a/lib/std/src/dynlib/mod.c.ri +++ b/lib/std/src/dynlib/mod.c.ri @@ -78,7 +78,7 @@ struct Library { _ = unsafe { libc.dlclose(self.ptr) }; } - func __drop__(self) { + func __destroy__(self) { self.close(); } } diff --git a/tests/invalid/directly_call_a_special_method.out b/tests/invalid/directly_call_a_special_method.out index 40e4e0220..9c61c8587 100644 --- a/tests/invalid/directly_call_a_special_method.out +++ b/tests/invalid/directly_call_a_special_method.out @@ -1,4 +1,4 @@ tests/invalid/directly_call_a_special_method.ri:9:5: error: cannot call a special method directly - 9 | d.__drop__(); - | ^~~~~~~~~~~~ + 9 | d.__destroy__(); + | ^~~~~~~~~~~~~~~ rivet: error: could not compile module `directly_call_a_special_method`, aborting due to previous error \ No newline at end of file diff --git a/tests/invalid/directly_call_a_special_method.ri b/tests/invalid/directly_call_a_special_method.ri index ddcde4be2..6dafc4564 100644 --- a/tests/invalid/directly_call_a_special_method.ri +++ b/tests/invalid/directly_call_a_special_method.ri @@ -1,10 +1,10 @@ -struct Dropper { - func __drop__(self) { +struct Destroyer { + func __destroy__(self) { _ = self; } } func main() { - d := Dropper(); - d.__drop__(); + d := Destroyer(); + d.__destroy__(); } diff --git a/tests/valid/src/special_methods.ri b/tests/valid/src/special_methods.ri index 5b26afd23..94acab0ed 100644 --- a/tests/valid/src/special_methods.ri +++ b/tests/valid/src/special_methods.ri @@ -1,5 +1,5 @@ struct SpecialMethods { - func __drop__(self) { + func __destroy__(self) { _ = self; } }