summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-01-23 21:42:05 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-01-23 21:42:15 +0900
commitaefb13eb631cc5cd784fe2fc10f1f333a2c5e68c (patch)
treefd1d57d7945a28b8dc0dca5175b9c87a449c56be /error.c
parent0ea759eac9234afc47e8fb1bcacfe9ee12c8ffb6 (diff)
Added rb_warn_deprecated_to_remove
Warn the deprecation and future removal, with obeying the warning flag.
Diffstat (limited to 'error.c')
-rw-r--r--error.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/error.c b/error.c
index 1702a709b4..b9ec8427e6 100644
--- a/error.c
+++ b/error.c
@@ -389,6 +389,20 @@ rb_warn_deprecated(const char *fmt, const char *suggest, ...)
rb_write_warning_str(mesg);
}
+void
+rb_warn_deprecated_to_remove(const char *fmt, const char *removal, ...)
+{
+ if (NIL_P(ruby_verbose)) return;
+ if (!rb_warning_category_enabled_p(RB_WARN_CATEGORY_DEPRECATED)) return;
+ va_list args;
+ va_start(args, removal);
+ VALUE mesg = warning_string(0, fmt, args);
+ va_end(args);
+ rb_str_set_len(mesg, RSTRING_LEN(mesg) - 1);
+ rb_str_catf(mesg, " is deprecated and will be removed in Ruby %s\n", removal);
+ rb_write_warning_str(mesg);
+}
+
static inline int
end_with_asciichar(VALUE str, int c)
{
@@ -3035,14 +3049,14 @@ rb_check_frozen(VALUE obj)
void
rb_error_untrusted(VALUE obj)
{
- rb_warn("rb_error_untrusted is deprecated and will be removed in Ruby 3.2.");
+ rb_warn_deprecated_to_remove("rb_error_untrusted", "3.2");
}
#undef rb_check_trusted
void
rb_check_trusted(VALUE obj)
{
- rb_warn("rb_check_trusted is deprecated and will be removed in Ruby 3.2.");
+ rb_warn_deprecated_to_remove("rb_check_trusted", "3.2");
}
void