@@ -52,8 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
5252
5353 let ty = cx. typeck_results ( ) . expr_ty ( arg) ;
5454
55- // let &ty::Adt(adt, args) = ty.kind() else { return };
56- let ( adt, args, _) = match ty. kind ( ) {
55+ let ( adt, args, ref_mutability) = match ty. kind ( ) {
5756 & ty:: Adt ( adt, args) => ( adt, args, None ) ,
5857 & ty:: Ref ( _, ty, mutability) => match ty. kind ( ) {
5958 & ty:: Adt ( adt, args) => ( adt, args, Some ( mutability) ) ,
@@ -68,6 +67,11 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
6867 _ => return ,
6968 } ;
7069
70+ let ref_prefix = match ref_mutability {
71+ None => "" ,
72+ Some ( ref_mutability) => ref_mutability. ref_prefix_str ( ) ,
73+ } ;
74+
7175 let sub = if let Some ( recv) = extract_iterator_next_call ( cx, arg)
7276 && let Ok ( recv_snip) = cx. sess ( ) . source_map ( ) . span_to_snippet ( recv. span )
7377 {
@@ -93,7 +97,7 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
9397 cx. emit_span_lint (
9498 FOR_LOOPS_OVER_FALLIBLES ,
9599 arg. span ,
96- ForLoopsOverFalliblesDiag { article, ty, sub, question_mark, suggestion } ,
100+ ForLoopsOverFalliblesDiag { article, ref_prefix , ty, sub, question_mark, suggestion } ,
97101 ) ;
98102 }
99103}
0 commit comments