1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Show the removal version

This commit is contained in:
Nobuyoshi Nakada 2020-12-28 19:17:52 +09:00
parent 8118d435d0
commit 0b726924a4
Notes: git 2021-06-30 10:47:37 +09:00
2 changed files with 10 additions and 8 deletions

12
error.c
View file

@ -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

View file

@ -49,7 +49,7 @@ NORETURN(void rb_async_bug_errno(const char *,int));
const char *rb_builtin_type_name(int t);
const char *rb_builtin_class_name(VALUE x);
PRINTF_ARGS(void rb_warn_deprecated(const char *fmt, const char *suggest, ...), 1, 3);
PRINTF_ARGS(void rb_warn_deprecated_to_remove(const char *fmt, const char *suggest, ...), 1, 3);
PRINTF_ARGS(void rb_warn_deprecated_to_remove(const char *removal, const char *fmt, const char *suggest, ...), 2, 4);
#if RUBY_DEBUG && (RBIMPL_HAS_ATTRIBUTE(diagnose_if) || defined(__OPTIMIZE__))
# include "ruby/version.h"
@ -88,10 +88,10 @@ void rb_deprecated_method_to_be_removed(const char *);
# endif
# define rb_warn_deprecated_to_remove_at(removal, ...) \
(rb_deprecated_method_to_be_removed(removal), \
rb_warn_deprecated_to_remove(__VA_ARGS__))
rb_warn_deprecated_to_remove(removal, __VA_ARGS__))
#else
# define rb_warn_deprecated_to_remove_at(removal, ...) \
rb_warn_deprecated_to_remove(__VA_ARGS__)
rb_warn_deprecated_to_remove(removal, __VA_ARGS__)
#endif
VALUE rb_syntax_error_append(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
PRINTF_ARGS(void rb_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);