зеркало из https://github.com/github/ruby.git
Use category: :experimental in warnings that are related to experimental features
This adds rb_category_compile_warn in order to emit compiler warnings with categories. Note that Ripper currently ignores the category for these warnings, but by default it ignores the warnings completely, so this shouldn't matter.
This commit is contained in:
Родитель
05313c914b
Коммит
7e2dbbda35
14
error.c
14
error.c
|
@ -375,6 +375,20 @@ rb_compile_warning(const char *file, int line, const char *fmt, ...)
|
|||
rb_write_warning_str(str);
|
||||
}
|
||||
|
||||
void
|
||||
rb_category_compile_warn(rb_warning_category_t category, const char *file, int line, const char *fmt, ...)
|
||||
{
|
||||
VALUE str;
|
||||
va_list args;
|
||||
|
||||
if (NIL_P(ruby_verbose)) return;
|
||||
|
||||
va_start(args, fmt);
|
||||
str = warn_vsprintf(NULL, file, line, fmt, args);
|
||||
va_end(args);
|
||||
rb_warn_category(str, rb_hash_fetch(warning_category_t_map, INT2NUM(category)));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
warning_string(rb_encoding *enc, const char *fmt, va_list args)
|
||||
{
|
||||
|
|
|
@ -70,12 +70,13 @@ VALUE *rb_ruby_debug_ptr(void);
|
|||
|
||||
/* reports if `-W' specified */
|
||||
PRINTF_ARGS(void rb_warning(const char*, ...), 1, 2);
|
||||
PRINTF_ARGS(void rb_category_warning(rb_warning_category_t category, const char*, ...), 2, 3);
|
||||
PRINTF_ARGS(void rb_category_warning(rb_warning_category_t, const char*, ...), 2, 3);
|
||||
PRINTF_ARGS(void rb_compile_warning(const char *, int, const char*, ...), 3, 4);
|
||||
PRINTF_ARGS(void rb_category_compile_warn(rb_warning_category_t, const char *, int, const char*, ...), 4, 5);
|
||||
PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2);
|
||||
/* reports always */
|
||||
COLDFUNC PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
|
||||
COLDFUNC PRINTF_ARGS(void rb_category_warn(rb_warning_category_t category, const char*, ...), 2, 3);
|
||||
COLDFUNC PRINTF_ARGS(void rb_category_warn(rb_warning_category_t, const char*, ...), 2, 3);
|
||||
PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
|
||||
|
||||
RBIMPL_SYMBOL_EXPORT_END()
|
||||
|
|
6
parse.y
6
parse.y
|
@ -1034,6 +1034,7 @@ static ID id_warn, id_warning, id_gets, id_assoc;
|
|||
# define WARN_ID(i) rb_id2str(i)
|
||||
# define WARN_IVAL(i) i
|
||||
# define PRIsWARN "s"
|
||||
# define rb_warn0L_experimental(l,fmt) WARN_CALL(WARN_ARGS_L(l, fmt, 1))
|
||||
# define WARN_ARGS(fmt,n) p->value, id_warn, n, rb_usascii_str_new_lit(fmt)
|
||||
# define WARN_ARGS_L(l,fmt,n) WARN_ARGS(fmt,n)
|
||||
# ifdef HAVE_VA_ARGS_MACRO
|
||||
|
@ -1060,6 +1061,7 @@ PRINTF_ARGS(static void ripper_compile_error(struct parser_params*, const char *
|
|||
# define WARN_ARGS(fmt,n) WARN_ARGS_L(p->ruby_sourceline,fmt,n)
|
||||
# define WARN_ARGS_L(l,fmt,n) p->ruby_sourcefile, (l), (fmt)
|
||||
# define WARN_CALL rb_compile_warn
|
||||
# define rb_warn0L_experimental(l,fmt) rb_category_compile_warn(RB_WARN_CATEGORY_EXPERIMENTAL, WARN_ARGS_L(l, fmt, 1))
|
||||
# define WARNING_ARGS(fmt,n) WARN_ARGS(fmt,n)
|
||||
# define WARNING_ARGS_L(l,fmt,n) WARN_ARGS_L(l,fmt,n)
|
||||
# define WARNING_CALL rb_compile_warning
|
||||
|
@ -4229,7 +4231,7 @@ p_find : p_rest ',' p_args_post ',' p_rest
|
|||
$$ = new_find_pattern_tail(p, $1, $3, $5, &@$);
|
||||
|
||||
if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL))
|
||||
rb_warn0L(nd_line($$), "Find pattern is experimental, and the behavior may change in future versions of Ruby!");
|
||||
rb_warn0L_experimental(nd_line($$), "Find pattern is experimental, and the behavior may change in future versions of Ruby!");
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -11955,7 +11957,7 @@ warn_one_line_pattern_matching(struct parser_params *p, NODE *node, NODE *patter
|
|||
|
||||
if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL) &&
|
||||
!(right_assign && (type == NODE_LASGN || type == NODE_DASGN || type == NODE_DASGN_CURR)))
|
||||
rb_warn0L(nd_line(node), "One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!");
|
||||
rb_warn0L_experimental(nd_line(node), "One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!");
|
||||
}
|
||||
|
||||
static NODE*
|
||||
|
|
5
ractor.c
5
ractor.c
|
@ -1394,8 +1394,9 @@ cancel_single_ractor_mode(void)
|
|||
rb_transient_heap_evacuate();
|
||||
|
||||
if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL)) {
|
||||
rb_warn("Ractor is experimental, and the behavior may change in future versions of Ruby! "
|
||||
"Also there are many implementation issues.");
|
||||
rb_category_warn(RB_WARN_CATEGORY_EXPERIMENTAL,
|
||||
"Ractor is experimental, and the behavior may change in future versions of Ruby! "
|
||||
"Also there are many implementation issues.");
|
||||
}
|
||||
|
||||
ruby_single_main_ractor = NULL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче