@@ -217,14 +217,12 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
217
217
for ref field in def. fields ( ) {
218
218
let def_id = cx. tcx . hir ( ) . local_def_id ( field. hir_id ) ;
219
219
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
+ )
228
226
}
229
227
}
230
228
}
@@ -242,15 +240,13 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
242
240
for field in fields {
243
241
let def_id = cx. tcx . hir ( ) . local_def_id ( field. hir_id ) ;
244
242
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
+ )
254
250
}
255
251
}
256
252
} ,
@@ -281,19 +277,17 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
281
277
282
278
for ( arg, ty) in decl. inputs . iter ( ) . zip ( sig. inputs ( ) . skip_binder ( ) . iter ( ) ) {
283
279
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 )
286
282
} )
287
283
}
288
284
}
289
285
290
286
if !in_new_function &&
291
287
is_unrooted_ty ( & self . symbols , cx, sig. output ( ) . skip_binder ( ) , false )
292
288
{
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 ( ) )
297
291
} )
298
292
}
299
293
}
@@ -322,11 +316,11 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
322
316
let require_rooted = |cx : & LateContext , in_new_function : bool , subexpr : & hir:: Expr | {
323
317
let ty = cx. typeck_results ( ) . expr_ty ( & subexpr) ;
324
318
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
+ )
330
324
}
331
325
} ;
332
326
@@ -364,11 +358,11 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
364
358
hir:: PatKind :: Binding ( hir:: BindingAnnotation :: MUT , ..) => {
365
359
let ty = cx. typeck_results ( ) . pat_ty ( pat) ;
366
360
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
+ )
372
366
}
373
367
} ,
374
368
_ => { } ,
0 commit comments