@@ -649,9 +649,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
649
649
}
650
650
}
651
651
652
- fn borrow_pat_suggestion ( & self , err : & mut Diagnostic , pat : & Pat < ' _ > , inner : & Pat < ' _ > ) {
652
+ // Precondition: pat is a Ref(_) pattern
653
+ fn borrow_pat_suggestion ( & self , err : & mut Diagnostic , pat : & Pat < ' _ > ) {
653
654
let tcx = self . tcx ;
654
- if let PatKind :: Ref ( _ , mutbl) = pat. kind
655
+ if let PatKind :: Ref ( inner , mutbl) = pat. kind
655
656
&& let PatKind :: Binding ( _, _, binding, ..) = inner. kind {
656
657
let binding_parent_id = tcx. hir ( ) . get_parent_node ( pat. hir_id ) ;
657
658
let binding_parent = tcx. hir ( ) . get ( binding_parent_id) ;
@@ -1835,6 +1836,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1835
1836
box_ty
1836
1837
}
1837
1838
1839
+ // Precondition: Pat is Ref(inner)
1838
1840
fn check_pat_ref (
1839
1841
& self ,
1840
1842
pat : & ' tcx Pat < ' tcx > ,
@@ -1868,7 +1870,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1868
1870
// Look for a case like `fn foo(&foo: u32)` and suggest
1869
1871
// `fn foo(foo: &u32)`
1870
1872
if let Some ( mut err) = err {
1871
- self . borrow_pat_suggestion ( & mut err, pat, inner ) ;
1873
+ self . borrow_pat_suggestion ( & mut err, pat) ;
1872
1874
err. emit ( ) ;
1873
1875
}
1874
1876
( rptr_ty, inner_ty)
0 commit comments