@@ -217,14 +217,12 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
217217 for ref field in def. fields ( ) {
218218 let def_id = cx. tcx . hir ( ) . local_def_id ( field. hir_id ) ;
219219 if is_unrooted_ty ( & self . symbols , cx, cx. tcx . type_of ( def_id) , false ) {
220- cx. lint ( UNROOTED_MUST_ROOT , |lint| {
221- lint. build (
222- "Type must be rooted, use #[unrooted_must_root_lint::must_root] \
223- on the struct definition to propagate",
224- )
225- . set_span ( field. span )
226- . emit ( )
227- } )
220+ cx. lint (
221+ UNROOTED_MUST_ROOT ,
222+ "Type must be rooted, use #[unrooted_must_root_lint::must_root] \
223+ on the struct definition to propagate",
224+ |lint| lint. set_span ( field. span ) ,
225+ )
228226 }
229227 }
230228 }
@@ -242,15 +240,13 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
242240 for field in fields {
243241 let def_id = cx. tcx . hir ( ) . local_def_id ( field. hir_id ) ;
244242 if is_unrooted_ty ( & self . symbols , cx, cx. tcx . type_of ( def_id) , false ) {
245- cx. lint ( UNROOTED_MUST_ROOT , |lint| {
246- lint. build (
247- "Type must be rooted, \
248- use #[unrooted_must_root_lint::must_root] \
249- on the enum definition to propagate",
250- )
251- . set_span ( field. ty . span )
252- . emit ( )
253- } )
243+ cx. lint (
244+ UNROOTED_MUST_ROOT ,
245+ "Type must be rooted, \
246+ use #[unrooted_must_root_lint::must_root] \
247+ on the enum definition to propagate",
248+ |lint| lint. set_span ( field. ty . span ) ,
249+ )
254250 }
255251 }
256252 } ,
@@ -281,19 +277,17 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
281277
282278 for ( arg, ty) in decl. inputs . iter ( ) . zip ( sig. inputs ( ) . skip_binder ( ) . iter ( ) ) {
283279 if is_unrooted_ty ( & self . symbols , cx, * ty, false ) {
284- cx. lint ( UNROOTED_MUST_ROOT , |lint| {
285- lint. build ( "Type must be rooted" ) . set_span ( arg. span ) . emit ( )
280+ cx. lint ( UNROOTED_MUST_ROOT , "Type must be rooted" , |lint| {
281+ lint. set_span ( arg. span )
286282 } )
287283 }
288284 }
289285
290286 if !in_new_function &&
291287 is_unrooted_ty ( & self . symbols , cx, sig. output ( ) . skip_binder ( ) , false )
292288 {
293- cx. lint ( UNROOTED_MUST_ROOT , |lint| {
294- lint. build ( "Type must be rooted" )
295- . set_span ( decl. output . span ( ) )
296- . emit ( )
289+ cx. lint ( UNROOTED_MUST_ROOT , "Type must be rooted" , |lint| {
290+ lint. set_span ( decl. output . span ( ) )
297291 } )
298292 }
299293 }
@@ -322,11 +316,11 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
322316 let require_rooted = |cx : & LateContext , in_new_function : bool , subexpr : & hir:: Expr | {
323317 let ty = cx. typeck_results ( ) . expr_ty ( & subexpr) ;
324318 if is_unrooted_ty ( & self . symbols , cx, ty, in_new_function) {
325- cx. lint ( UNROOTED_MUST_ROOT , |lint| {
326- lint . build ( & format ! ( "Expression of type {:?} must be rooted" , ty ) )
327- . set_span ( subexpr . span )
328- . emit ( )
329- } )
319+ cx. lint (
320+ UNROOTED_MUST_ROOT ,
321+ format ! ( "Expression of type {:?} must be rooted" , ty ) ,
322+ |lint| lint . set_span ( subexpr . span ) ,
323+ )
330324 }
331325 } ;
332326
@@ -364,11 +358,11 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
364358 hir:: PatKind :: Binding ( hir:: BindingAnnotation :: MUT , ..) => {
365359 let ty = cx. typeck_results ( ) . pat_ty ( pat) ;
366360 if is_unrooted_ty ( self . symbols , cx, ty, self . in_new_function ) {
367- cx. lint ( UNROOTED_MUST_ROOT , |lint| {
368- lint . build ( & format ! ( "Expression of type {:?} must be rooted" , ty ) )
369- . set_span ( pat . span )
370- . emit ( )
371- } )
361+ cx. lint (
362+ UNROOTED_MUST_ROOT ,
363+ format ! ( "Expression of type {:?} must be rooted" , ty ) ,
364+ |lint| lint . set_span ( pat . span ) ,
365+ )
372366 }
373367 } ,
374368 _ => { } ,
0 commit comments