@@ -187,14 +187,13 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
187
187
for field in def. fields ( ) {
188
188
let field_type = cx. tcx . type_of ( field. def_id ) ;
189
189
if is_unrooted_ty ( & self . symbols , cx, field_type. skip_binder ( ) , false ) {
190
- cx. lint (
191
- UNROOTED_MUST_ROOT ,
192
- "Type must be rooted, use #[crown::unrooted_must_root_lint::must_root] \
193
- on the struct definition to propagate",
194
- |lint| {
195
- lint. span ( field. span ) ;
196
- } ,
197
- )
190
+ cx. lint ( UNROOTED_MUST_ROOT , |lint| {
191
+ lint. primary_message (
192
+ "Type must be rooted, use #[crown::unrooted_must_root_lint::must_root] \
193
+ on the struct definition to propagate"
194
+ ) ;
195
+ lint. span ( field. span ) ;
196
+ } )
198
197
}
199
198
}
200
199
}
@@ -212,15 +211,14 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
212
211
for field in fields {
213
212
let field_type = cx. tcx . type_of ( field. def_id ) ;
214
213
if is_unrooted_ty ( & self . symbols , cx, field_type. skip_binder ( ) , false ) {
215
- cx. lint (
216
- UNROOTED_MUST_ROOT ,
217
- "Type must be rooted, \
218
- use #[crown::unrooted_must_root_lint::must_root] \
219
- on the enum definition to propagate",
220
- |lint| {
221
- lint. span ( field. ty . span ) ;
222
- } ,
223
- )
214
+ cx. lint ( UNROOTED_MUST_ROOT , |lint| {
215
+ lint. primary_message (
216
+ "Type must be rooted, \
217
+ use #[crown::unrooted_must_root_lint::must_root] \
218
+ on the enum definition to propagate",
219
+ ) ;
220
+ lint. span ( field. ty . span ) ;
221
+ } )
224
222
}
225
223
}
226
224
} ,
@@ -250,7 +248,8 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
250
248
251
249
for ( arg, ty) in decl. inputs . iter ( ) . zip ( sig. inputs ( ) . skip_binder ( ) . iter ( ) ) {
252
250
if is_unrooted_ty ( & self . symbols , cx, * ty, false ) {
253
- cx. lint ( UNROOTED_MUST_ROOT , "Type must be rooted" , |lint| {
251
+ cx. lint ( UNROOTED_MUST_ROOT , |lint| {
252
+ lint. primary_message ( "Type must be rooted" ) ;
254
253
lint. span ( arg. span ) ;
255
254
} )
256
255
}
@@ -259,7 +258,8 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
259
258
if !in_new_function &&
260
259
is_unrooted_ty ( & self . symbols , cx, sig. output ( ) . skip_binder ( ) , false )
261
260
{
262
- cx. lint ( UNROOTED_MUST_ROOT , "Type must be rooted" , |lint| {
261
+ cx. lint ( UNROOTED_MUST_ROOT , |lint| {
262
+ lint. primary_message ( "Type must be rooted" ) ;
263
263
lint. span ( decl. output . span ( ) ) ;
264
264
} )
265
265
}
@@ -289,13 +289,10 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
289
289
let require_rooted = |cx : & LateContext , in_new_function : bool , subexpr : & hir:: Expr | {
290
290
let ty = cx. typeck_results ( ) . expr_ty ( subexpr) ;
291
291
if is_unrooted_ty ( self . symbols , cx, ty, in_new_function) {
292
- cx. lint (
293
- UNROOTED_MUST_ROOT ,
294
- format ! ( "Expression of type {:?} must be rooted" , ty) ,
295
- |lint| {
296
- lint. span ( subexpr. span ) ;
297
- } ,
298
- )
292
+ cx. lint ( UNROOTED_MUST_ROOT , |lint| {
293
+ lint. primary_message ( format ! ( "Expression of type {:?} must be rooted" , ty) ) ;
294
+ lint. span ( subexpr. span ) ;
295
+ } )
299
296
}
300
297
} ;
301
298
@@ -329,17 +326,14 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
329
326
// are implemented, the `Unannotated` case could cause false-positives.
330
327
// These should be fixable by adding an explicit `ref`.
331
328
match pat. kind {
332
- hir:: PatKind :: Binding ( hir:: BindingAnnotation :: NONE , ..) |
333
- hir:: PatKind :: Binding ( hir:: BindingAnnotation :: MUT , ..) => {
329
+ hir:: PatKind :: Binding ( hir:: BindingMode :: NONE , ..) |
330
+ hir:: PatKind :: Binding ( hir:: BindingMode :: MUT , ..) => {
334
331
let ty = cx. typeck_results ( ) . pat_ty ( pat) ;
335
332
if is_unrooted_ty ( self . symbols , cx, ty, self . in_new_function ) {
336
- cx. lint (
337
- UNROOTED_MUST_ROOT ,
338
- format ! ( "Expression of type {:?} must be rooted" , ty) ,
339
- |lint| {
340
- lint. span ( pat. span ) ;
341
- } ,
342
- )
333
+ cx. lint ( UNROOTED_MUST_ROOT , |lint| {
334
+ lint. primary_message ( format ! ( "Expression of type {:?} must be rooted" , ty) ) ;
335
+ lint. span ( pat. span ) ;
336
+ } )
343
337
}
344
338
} ,
345
339
_ => { } ,
0 commit comments