summaryrefslogtreecommitdiff
path: root/internal/string.h
diff options
context:
space:
mode:
authorÉtienne Barrié <[email protected]>2024-10-14 11:28:59 +0200
committerJean Boussier <[email protected]>2024-10-21 12:33:02 +0200
commit257f78fb671151f1db06dcd8e35cf4cc736f735e (patch)
treecf67eb44cc8134d82eac7d688b23fe33a9ba7910 /internal/string.h
parent75ef89ca16d2c94e845b80e8b97bfc811370a890 (diff)
Show where mutated chilled strings were allocated
[Feature #20205] The warning now suggests running with --debug-frozen-string-literal: ``` test.rb:3: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information) ``` When using --debug-frozen-string-literal, the location where the string was created is shown: ``` test.rb:3: warning: literal string will be frozen in the future test.rb:1: info: the string was created here ``` When resurrecting strings and debug mode is not enabled, the overhead is a simple FL_TEST_RAW. When mutating chilled strings and deprecation warnings are not enabled, the overhead is a simple warning category enabled check. Co-authored-by: Jean Boussier <[email protected]> Co-authored-by: Nobuyoshi Nakada <[email protected]> Co-authored-by: Jean Boussier <[email protected]>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11893
Diffstat (limited to 'internal/string.h')
-rw-r--r--internal/string.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/string.h b/internal/string.h
index 10879bd1d9..81e94ed6b5 100644
--- a/internal/string.h
+++ b/internal/string.h
@@ -57,6 +57,10 @@ VALUE rb_str_upto_each(VALUE, VALUE, int, int (*each)(VALUE, VALUE), VALUE);
size_t rb_str_size_as_embedded(VALUE);
bool rb_str_reembeddable_p(VALUE);
VALUE rb_str_upto_endless_each(VALUE, int (*each)(VALUE, VALUE), VALUE);
+VALUE rb_str_with_debug_created_info(VALUE, VALUE, int);
+
+/* error.c */
+void rb_warn_unchilled(VALUE str);
static inline bool STR_EMBED_P(VALUE str);
static inline bool STR_SHARED_P(VALUE str);
@@ -124,7 +128,7 @@ static inline void
CHILLED_STRING_MUTATED(VALUE str)
{
FL_UNSET_RAW(str, STR_CHILLED);
- rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "literal string will be frozen in the future");
+ rb_warn_unchilled(str);
}
static inline void