@@ -31,6 +31,18 @@ pub struct FnProperties {
3131 pub elidable : bool ,
3232}
3333
34+ /// A safe default for un-annotated Ruby methods: we can't optimize them or their returned values.
35+ impl Default for FnProperties {
36+ fn default ( ) -> Self {
37+ Self {
38+ no_gc : false ,
39+ leaf : false ,
40+ return_type : types:: BasicObject ,
41+ elidable : false ,
42+ }
43+ }
44+ }
45+
3446impl Annotations {
3547 /// Query about properties of a C method
3648 pub fn get_cfunc_properties ( & self , method : * const rb_callable_method_entry_t ) -> Option < FnProperties > {
@@ -140,11 +152,12 @@ pub fn init() -> Annotations {
140152 let builtin_funcs = & mut HashMap :: new ( ) ;
141153
142154 macro_rules! annotate {
143- ( $module: ident, $method_name: literal, $return_type: expr, $( $properties: ident) ,+) => {
155+ ( $module: ident, $method_name: literal, $return_type: expr $( , $properties: ident) * ) => {
156+ #[ allow( unused_mut) ]
144157 let mut props = FnProperties { no_gc: false , leaf: false , elidable: false , return_type: $return_type } ;
145158 $(
146159 props. $properties = true ;
147- ) +
160+ ) *
148161 annotate_c_method( cfuncs, unsafe { $module } , $method_name, props) ;
149162 }
150163 }
@@ -167,11 +180,14 @@ pub fn init() -> Annotations {
167180
168181 annotate ! ( rb_mKernel, "itself" , types:: BasicObject , no_gc, leaf, elidable) ;
169182 annotate ! ( rb_cString, "bytesize" , types:: Fixnum , no_gc, leaf) ;
183+ annotate ! ( rb_cString, "to_s" , types:: StringExact ) ;
170184 annotate ! ( rb_cModule, "name" , types:: StringExact . union ( types:: NilClass ) , no_gc, leaf, elidable) ;
171185 annotate ! ( rb_cModule, "===" , types:: BoolExact , no_gc, leaf) ;
172186 annotate ! ( rb_cArray, "length" , types:: Fixnum , no_gc, leaf, elidable) ;
173187 annotate ! ( rb_cArray, "size" , types:: Fixnum , no_gc, leaf, elidable) ;
174188 annotate ! ( rb_cArray, "empty?" , types:: BoolExact , no_gc, leaf, elidable) ;
189+ annotate ! ( rb_cArray, "reverse" , types:: ArrayExact , leaf, elidable) ;
190+ annotate ! ( rb_cArray, "join" , types:: StringExact ) ;
175191 annotate ! ( rb_cHash, "empty?" , types:: BoolExact , no_gc, leaf, elidable) ;
176192 annotate ! ( rb_cNilClass, "nil?" , types:: TrueClass , no_gc, leaf, elidable) ;
177193 annotate ! ( rb_mKernel, "nil?" , types:: FalseClass , no_gc, leaf, elidable) ;
0 commit comments