summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-28 19:17:52 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-06-30 10:47:01 +0900
commit0b726924a4ac6a09b33d0f7d082c30d667b7564e (patch)
tree3fb8d215ba58d464badae3ce846533efdd0d9ed3 /error.c
parent8118d435d000adec3023a0ff509baa11cc73fabb (diff)
Show the removal version
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3972
Diffstat (limited to 'error.c')
-rw-r--r--error.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/error.c b/error.c
index c719d54960..6e08e64a31 100644
--- a/error.c
+++ b/error.c
@@ -493,11 +493,13 @@ deprecation_warning_enabled(void)
}
static void
-warn_deprecated(VALUE mesg, bool removal, const char *suggest)
+warn_deprecated(VALUE mesg, const char *removal, const char *suggest)
{
rb_str_set_len(mesg, RSTRING_LEN(mesg) - 1);
rb_str_cat_cstr(mesg, " is deprecated");
- if (removal) rb_str_cat_cstr(mesg, ", and is planned for removal");
+ if (removal) {
+ rb_str_catf(mesg, " and will be removed in Ruby %s", removal);
+ }
if (suggest) rb_str_catf(mesg, "; use %s instead", suggest);
rb_str_cat_cstr(mesg, "\n");
rb_warn_category(mesg, ID2SYM(id_deprecated));
@@ -513,11 +515,11 @@ rb_warn_deprecated(const char *fmt, const char *suggest, ...)
VALUE mesg = warning_string(0, fmt, args);
va_end(args);
- warn_deprecated(mesg, false, suggest);
+ warn_deprecated(mesg, NULL, suggest);
}
void
-rb_warn_deprecated_to_remove(const char *fmt, const char *suggest, ...)
+rb_warn_deprecated_to_remove(const char *removal, const char *fmt, const char *suggest, ...)
{
if (!deprecation_warning_enabled()) return;
@@ -526,7 +528,7 @@ rb_warn_deprecated_to_remove(const char *fmt, const char *suggest, ...)
VALUE mesg = warning_string(0, fmt, args);
va_end(args);
- warn_deprecated(mesg, true, suggest);
+ warn_deprecated(mesg, removal, suggest);
}
static inline int