@@ -187,14 +187,13 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
187187 for field in def. fields ( ) {
188188 let field_type = cx. tcx . type_of ( field. def_id ) ;
189189 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+ } )
198197 }
199198 }
200199 }
@@ -212,15 +211,14 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
212211 for field in fields {
213212 let field_type = cx. tcx . type_of ( field. def_id ) ;
214213 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+ } )
224222 }
225223 }
226224 } ,
@@ -250,7 +248,8 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
250248
251249 for ( arg, ty) in decl. inputs . iter ( ) . zip ( sig. inputs ( ) . skip_binder ( ) . iter ( ) ) {
252250 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" ) ;
254253 lint. span ( arg. span ) ;
255254 } )
256255 }
@@ -259,7 +258,8 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
259258 if !in_new_function &&
260259 is_unrooted_ty ( & self . symbols , cx, sig. output ( ) . skip_binder ( ) , false )
261260 {
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" ) ;
263263 lint. span ( decl. output . span ( ) ) ;
264264 } )
265265 }
@@ -289,13 +289,10 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
289289 let require_rooted = |cx : & LateContext , in_new_function : bool , subexpr : & hir:: Expr | {
290290 let ty = cx. typeck_results ( ) . expr_ty ( subexpr) ;
291291 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+ } )
299296 }
300297 } ;
301298
@@ -329,17 +326,14 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
329326 // are implemented, the `Unannotated` case could cause false-positives.
330327 // These should be fixable by adding an explicit `ref`.
331328 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 , ..) => {
334331 let ty = cx. typeck_results ( ) . pat_ty ( pat) ;
335332 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+ } )
343337 }
344338 } ,
345339 _ => { } ,
0 commit comments