@@ -104,19 +104,14 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
104
104
return DummyResult :: expr ( sp) ;
105
105
}
106
106
107
- let e = cx. expr_vec_slice ( sp, bytes) ;
108
- let ty = cx. ty ( sp, ast:: TyVec ( cx. ty_ident ( sp, cx. ident_of ( "u8" ) ) ) ) ;
109
- let lifetime = cx. lifetime ( sp, cx. ident_of ( "'static" ) . name ) ;
110
- let item = cx. item_static ( sp,
111
- cx. ident_of ( "BYTES" ) ,
112
- cx. ty_rptr ( sp,
113
- ty,
114
- Some ( lifetime) ,
115
- ast:: MutImmutable ) ,
116
- ast:: MutImmutable ,
117
- e) ;
118
- let e = cx. expr_block ( cx. block ( sp,
119
- vec ! ( cx. stmt_item( sp, item) ) ,
120
- Some ( cx. expr_ident ( sp, cx. ident_of ( "BYTES" ) ) ) ) ) ;
107
+ let len = bytes. len ( ) ;
108
+ let e = cx. expr_vec ( sp, bytes) ;
109
+ let ty = cx. ty ( sp, ast:: TyFixedLengthVec ( cx. ty_ident ( sp, cx. ident_of ( "u8" ) ) ,
110
+ cx. expr_uint ( sp, len) ) ) ;
111
+ let item = cx. item_static ( sp, cx. ident_of ( "BYTES" ) , ty, ast:: MutImmutable , e) ;
112
+ let ret = cx. expr_ident ( sp, cx. ident_of ( "BYTES" ) ) ;
113
+ let ret = cx. expr_addr_of ( sp, ret) ;
114
+ let e = cx. expr_block ( cx. block ( sp, vec ! [ cx. stmt_item( sp, item) ] ,
115
+ Some ( ret) ) ) ;
121
116
MacExpr :: new ( e)
122
117
}
0 commit comments