@@ -145,39 +145,34 @@ pub fn get_drop_glue(ccx: &CrateContext, t: ty::t) -> ValueRef {
145145 glue
146146}
147147
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 {
149149 let _icx = push_ctxt ( "lazily_emit_visit_glue" ) ;
150150
151151 let llfnty = Type :: glue_fn ( ccx, type_of ( ccx, ti. ty ) . ptr_to ( ) ) ;
152152
153153 match ti. visit_glue . get ( ) {
154- Some ( _ ) => ( ) ,
154+ Some ( visit_glue ) => visit_glue ,
155155 None => {
156156 debug ! ( "+++ lazily_emit_tydesc_glue VISIT {}" , ppaux:: ty_to_str( ccx. tcx( ) , ti. ty) ) ;
157157 let glue_fn = declare_generic_glue ( ccx, ti. ty , llfnty, "visit" ) ;
158158 ti. visit_glue . set ( Some ( glue_fn) ) ;
159159 make_generic_glue ( ccx, ti. ty , glue_fn, make_visit_glue, "visit" ) ;
160160 debug ! ( "--- lazily_emit_tydesc_glue VISIT {}" , ppaux:: ty_to_str( ccx. tcx( ) , ti. ty) ) ;
161+ glue_fn
161162 }
162163 }
163164}
164165
165166// See [Note-arg-mode]
166167pub fn call_visit_glue ( bcx : & Block , v : ValueRef , tydesc : ValueRef ,
167- static_ti : Option < @ tydesc_info > ) {
168+ static_ti : Option < & tydesc_info > ) {
168169 let _icx = push_ctxt ( "call_tydesc_glue_full" ) ;
169170 let ccx = bcx. ccx ( ) ;
170171 // NB: Don't short-circuit even if this block is unreachable because
171172 // GC-based cleanup needs to the see that the roots are live.
172173 if bcx. unreachable . get ( ) && !ccx. sess ( ) . no_landing_pads ( ) { return ; }
173174
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) ) ;
181176
182177 // When static type info is available, avoid casting to a generic pointer.
183178 let llrawptr = if static_glue_fn. is_none ( ) {
@@ -404,7 +399,7 @@ fn incr_refcnt_of_boxed<'a>(bcx: &'a Block<'a>,
404399
405400
406401// 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 {
408403 // If emit_tydescs already ran, then we shouldn't be creating any new
409404 // tydescs.
410405 assert ! ( !ccx. finished_tydescs. get( ) ) ;
@@ -430,16 +425,15 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> @tydesc_info {
430425 let ty_name = token:: intern_and_get_ident ( ppaux:: ty_to_str ( ccx. tcx ( ) , t) ) ;
431426 let ty_name = C_str_slice ( ccx, ty_name) ;
432427
433- let inf = @tydesc_info {
428+ debug ! ( "--- declare_tydesc {}" , ppaux:: ty_to_str( ccx. tcx( ) , t) ) ;
429+ tydesc_info {
434430 ty : t,
435431 tydesc : gvar,
436432 size : llsize,
437433 align : llalign,
438434 name : ty_name,
439435 visit_glue : Cell :: new ( None ) ,
440- } ;
441- debug ! ( "--- declare_tydesc {}" , ppaux:: ty_to_str( ccx. tcx( ) , t) ) ;
442- return inf;
436+ }
443437}
444438
445439fn declare_generic_glue ( ccx : & CrateContext , t : ty:: t , llfnty : Type ,
@@ -491,9 +485,7 @@ pub fn emit_tydescs(ccx: &CrateContext) {
491485 // As of this point, allow no more tydescs to be created.
492486 ccx. finished_tydescs. set( true ) ;
493487 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 ( ) {
497489 // Each of the glue functions needs to be cast to a generic type
498490 // before being put into the tydesc because we only have a singleton
499491 // tydesc type. Then we'll recast each function to its real type when
0 commit comments