From 471c140943b7e3f56b207757abb51a82765dfe99 Mon Sep 17 00:00:00 2001 From: Mat Sadler Date: Fri, 18 Nov 2022 20:19:43 -0800 Subject: [PATCH] remove deprecated code --- CHANGELOG.md | 3 +++ src/lib.rs | 6 ------ src/r_string.rs | 10 ---------- src/rb_sys.rs | 8 ++++---- src/value.rs | 27 +++------------------------ 5 files changed, 10 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 931c73e8..b7f8258b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,9 @@ (use `free_immediately`). ### Removed +- `String::encode_utf8`, use `r_string.conv_enc(RbEncoding::utf8())` instead. +- `Value::leak`, use `gc::register_mark_object` instead. +- `define_global_variable` (use `define_variable`). ### Fixed - Memory leak of the message when returning an `Error` to raise an exception. diff --git a/src/lib.rs b/src/lib.rs index be510860..3385bc86 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1952,12 +1952,6 @@ pub fn define_variable>(name: &str, initial: T) -> Result<*mut Va Ok(ptr) } -/// Define a global variable. -#[deprecated(since = "0.3.0", note = "please use `define_variable` instead")] -pub fn define_global_variable>(name: &str, initial: T) -> Result<*mut Value, Error> { - define_variable(name, initial) -} - /// Define a global constant. pub fn define_global_const(name: &str, value: T) -> Result<(), Error> where diff --git a/src/r_string.rs b/src/r_string.rs index ed2016c6..64a0dc9a 100644 --- a/src/r_string.rs +++ b/src/r_string.rs @@ -462,16 +462,6 @@ impl RString { encindex == encoding::Index::utf8() || encindex == encoding::Index::usascii() } - /// Returns a new string by reencoding `self` from its current encoding to - /// UTF-8. - #[deprecated( - since = "0.3.0", - note = "please use `r_string.conv_enc(RbEncoding::utf8())` instead" - )] - pub fn encode_utf8(self) -> Result { - self.conv_enc(RbEncoding::utf8()) - } - /// Returns a new string by reencoding `self` from its current encoding to /// the given `enc`. /// diff --git a/src/rb_sys.rs b/src/rb_sys.rs index fe6f11a8..0459c0b0 100644 --- a/src/rb_sys.rs +++ b/src/rb_sys.rs @@ -195,7 +195,7 @@ pub unsafe fn resume_error(e: Error) -> ! { } /// Convert [`magnus::Value`](Value) to [`rb_sys::VALUE`]. -#[deprecated(since = "0.3.3", note = "please use `Value::as_raw` instead")] +#[deprecated(since = "0.4.0", note = "please use `Value::as_raw` instead")] pub fn raw_value(val: Value) -> VALUE { val.as_raw() } @@ -207,13 +207,13 @@ pub fn raw_value(val: Value) -> VALUE { /// You must only supply a valid [`VALUE`] obtained from [rb-sys](rb_sys) to /// this function. Using a invalid [`Value`] produced from this function will /// void all saftey guarantees provided by Magnus. -#[deprecated(since = "0.3.3", note = "please use `Value::from_raw` instead")] +#[deprecated(since = "0.4.0", note = "please use `Value::from_raw` instead")] pub unsafe fn value_from_raw(val: VALUE) -> Value { Value::from_raw(val) } /// Convert [`magnus::value::Id`](Id) to [`rb_sys::ID`]. -#[deprecated(since = "0.3.3", note = "please use `Id::as_raw` instead")] +#[deprecated(since = "0.4.0", note = "please use `Id::as_raw` instead")] pub fn raw_id(id: Id) -> ID { id.as_raw() } @@ -225,7 +225,7 @@ pub fn raw_id(id: Id) -> ID { /// You must only supply a valid [`ID`] obtained from [rb-sys](rb_sys) to this /// function. Using a invalid [`Id`] produced from this function will void all /// saftey guarantees provided by Magnus. -#[deprecated(since = "0.3.3", note = "please use `Id::from_raw` instead")] +#[deprecated(since = "0.4.0", note = "please use `Id::from_raw` instead")] pub unsafe fn id_from_raw(id: ID) -> Id { Id::from_raw(id) } diff --git a/src/value.rs b/src/value.rs index 2ff43c73..d0e15061 100644 --- a/src/value.rs +++ b/src/value.rs @@ -20,9 +20,9 @@ pub use flonum::Flonum; use rb_sys::{ rb_any_to_s, rb_block_call, rb_check_funcall, rb_check_id, rb_check_id_cstr, rb_check_symbol_cstr, rb_enumeratorize_with_size, rb_eql, rb_equal, rb_funcall_with_block, - rb_funcallv, rb_gc_register_address, rb_gc_register_mark_object, rb_gc_unregister_address, - rb_id2name, rb_id2sym, rb_inspect, rb_intern3, rb_ll2inum, rb_obj_as_string, rb_obj_classname, - rb_obj_freeze, rb_obj_is_kind_of, rb_obj_respond_to, rb_sym2id, rb_ull2inum, ruby_fl_type, + rb_funcallv, rb_gc_register_address, rb_gc_unregister_address, rb_id2name, rb_id2sym, + rb_inspect, rb_intern3, rb_ll2inum, rb_obj_as_string, rb_obj_classname, rb_obj_freeze, + rb_obj_is_kind_of, rb_obj_respond_to, rb_sym2id, rb_ull2inum, ruby_fl_type, ruby_special_consts, ruby_value_type, RBasic, ID, VALUE, }; @@ -348,27 +348,6 @@ impl Value { self.0 } - /// Registers `self` as to never be garbage collected. - /// - /// # Examples - /// - /// ``` - /// use magnus::{eval, RArray}; - /// # let _cleanup = unsafe { magnus::embed::init() }; - /// - /// let ary = eval::("[1, 2, 3]").unwrap(); - /// ary.leak(); - /// ``` - #[deprecated( - since = "0.3.0", - note = "please use `gc::register_mark_object` instead" - )] - pub fn leak(self) { - debug_assert_value!(self); - // safe ffi to Ruby, call doesn't raise - unsafe { rb_gc_register_mark_object(self.as_rb_value()) } - } - /// Returns whether `self` is 'frozen'. /// /// Ruby prevents modifying frozen objects.