@@ -145,39 +145,34 @@ pub fn get_drop_glue(ccx: &CrateContext, t: ty::t) -> ValueRef {
145
145
glue
146
146
}
147
147
148
- pub fn lazily_emit_visit_glue ( ccx : & CrateContext , ti : @ tydesc_info ) {
148
+ pub fn lazily_emit_visit_glue ( ccx : & CrateContext , ti : & tydesc_info ) -> ValueRef {
149
149
let _icx = push_ctxt ( "lazily_emit_visit_glue" ) ;
150
150
151
151
let llfnty = Type :: glue_fn ( ccx, type_of ( ccx, ti. ty ) . ptr_to ( ) ) ;
152
152
153
153
match ti. visit_glue . get ( ) {
154
- Some ( _ ) => ( ) ,
154
+ Some ( visit_glue ) => visit_glue ,
155
155
None => {
156
156
debug ! ( "+++ lazily_emit_tydesc_glue VISIT {}" , ppaux:: ty_to_str( ccx. tcx( ) , ti. ty) ) ;
157
157
let glue_fn = declare_generic_glue ( ccx, ti. ty , llfnty, "visit" ) ;
158
158
ti. visit_glue . set ( Some ( glue_fn) ) ;
159
159
make_generic_glue ( ccx, ti. ty , glue_fn, make_visit_glue, "visit" ) ;
160
160
debug ! ( "--- lazily_emit_tydesc_glue VISIT {}" , ppaux:: ty_to_str( ccx. tcx( ) , ti. ty) ) ;
161
+ glue_fn
161
162
}
162
163
}
163
164
}
164
165
165
166
// See [Note-arg-mode]
166
167
pub fn call_visit_glue ( bcx : & Block , v : ValueRef , tydesc : ValueRef ,
167
- static_ti : Option < @ tydesc_info > ) {
168
+ static_ti : Option < & tydesc_info > ) {
168
169
let _icx = push_ctxt ( "call_tydesc_glue_full" ) ;
169
170
let ccx = bcx. ccx ( ) ;
170
171
// NB: Don't short-circuit even if this block is unreachable because
171
172
// GC-based cleanup needs to the see that the roots are live.
172
173
if bcx. unreachable . get ( ) && !ccx. sess ( ) . no_landing_pads ( ) { return ; }
173
174
174
- let static_glue_fn = match static_ti {
175
- None => None ,
176
- Some ( sti) => {
177
- lazily_emit_visit_glue ( ccx, sti) ;
178
- sti. visit_glue . get ( )
179
- }
180
- } ;
175
+ let static_glue_fn = static_ti. map ( |sti| lazily_emit_visit_glue ( ccx, sti) ) ;
181
176
182
177
// When static type info is available, avoid casting to a generic pointer.
183
178
let llrawptr = if static_glue_fn. is_none ( ) {
@@ -404,7 +399,7 @@ fn incr_refcnt_of_boxed<'a>(bcx: &'a Block<'a>,
404
399
405
400
406
401
// Generates the declaration for (but doesn't emit) a type descriptor.
407
- pub fn declare_tydesc ( ccx : & CrateContext , t : ty:: t ) -> @ tydesc_info {
402
+ pub fn declare_tydesc ( ccx : & CrateContext , t : ty:: t ) -> tydesc_info {
408
403
// If emit_tydescs already ran, then we shouldn't be creating any new
409
404
// tydescs.
410
405
assert ! ( !ccx. finished_tydescs. get( ) ) ;
@@ -430,16 +425,15 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> @tydesc_info {
430
425
let ty_name = token:: intern_and_get_ident ( ppaux:: ty_to_str ( ccx. tcx ( ) , t) ) ;
431
426
let ty_name = C_str_slice ( ccx, ty_name) ;
432
427
433
- let inf = @tydesc_info {
428
+ debug ! ( "--- declare_tydesc {}" , ppaux:: ty_to_str( ccx. tcx( ) , t) ) ;
429
+ tydesc_info {
434
430
ty : t,
435
431
tydesc : gvar,
436
432
size : llsize,
437
433
align : llalign,
438
434
name : ty_name,
439
435
visit_glue : Cell :: new ( None ) ,
440
- } ;
441
- debug ! ( "--- declare_tydesc {}" , ppaux:: ty_to_str( ccx. tcx( ) , t) ) ;
442
- return inf;
436
+ }
443
437
}
444
438
445
439
fn declare_generic_glue ( ccx : & CrateContext , t : ty:: t , llfnty : Type ,
@@ -491,9 +485,7 @@ pub fn emit_tydescs(ccx: &CrateContext) {
491
485
// As of this point, allow no more tydescs to be created.
492
486
ccx. finished_tydescs. set( true ) ;
493
487
let glue_fn_ty = Type :: generic_glue_fn ( ccx ) . ptr_to( ) ;
494
- for ( _, & val) in ccx. tydescs. borrow( ) . iter ( ) {
495
- let ti = val;
496
-
488
+ for ( _, ti) in ccx. tydescs. borrow( ) . iter ( ) {
497
489
// Each of the glue functions needs to be cast to a generic type
498
490
// before being put into the tydesc because we only have a singleton
499
491
// tydesc type. Then we'll recast each function to its real type when
0 commit comments