aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-12-16 09:02:23 -0800
committerJeremy Evans <code@jeremyevans.net>2020-12-18 09:54:11 -0800
commit7e2dbbda357b8c509358a3aa10ff6d588ed819e2 (patch)
treeebeeb8602567a3d7bffe381db269894167811a8f /error.c
parent05313c914b29f7027b27a91021ae2662f0149e54 (diff)
downloadruby-7e2dbbda357b8c509358a3aa10ff6d588ed819e2.tar.gz
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.
Diffstat (limited to 'error.c')
-rw-r--r--error.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/error.c b/error.c
index 7a7d5622e5..ce3dc1132c 100644
--- a/error.c
+++ b/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)
{