@@ -1662,7 +1662,16 @@ fn check_for_mutation(
1662
1662
} ;
1663
1663
let def_id = def_id:: DefId :: local ( body. hir_id . owner ) ;
1664
1664
let region_scope_tree = & cx. tcx . region_scope_tree ( def_id) ;
1665
- ExprUseVisitor :: new ( & mut delegate, cx. tcx , cx. param_env , region_scope_tree, cx. tables , None ) . walk_expr ( body) ;
1665
+ ExprUseVisitor :: new (
1666
+ & mut delegate,
1667
+ cx. tcx ,
1668
+ def_id,
1669
+ cx. param_env ,
1670
+ region_scope_tree,
1671
+ cx. tables ,
1672
+ None ,
1673
+ )
1674
+ . walk_expr ( body) ;
1666
1675
delegate. mutation_span ( )
1667
1676
}
1668
1677
@@ -1769,7 +1778,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
1769
1778
}
1770
1779
let res = self . cx. tables. qpath_res( seqpath, seqexpr. hir_id) ;
1771
1780
match res {
1772
- Res :: Local ( hir_id) | Res :: Upvar ( hir_id , .. ) => {
1781
+ Res :: Local ( hir_id) => {
1773
1782
let parent_id = self . cx. tcx. hir( ) . get_parent_item( expr. hir_id) ;
1774
1783
let parent_def_id = self . cx. tcx. hir( ) . local_def_id_from_hir_id( parent_id) ;
1775
1784
let extent = self . cx. tcx. region_scope_tree( parent_def_id) . var_scope( hir_id. local_id) ;
@@ -1829,24 +1838,13 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
1829
1838
if let QPath :: Resolved ( None , ref path) = * qpath;
1830
1839
if path. segments. len( ) == 1 ;
1831
1840
then {
1832
- match self . cx. tables. qpath_res( qpath, expr. hir_id) {
1833
- Res :: Upvar ( local_id, ..) => {
1834
- if local_id == self . var {
1835
- // we are not indexing anything, record that
1836
- self . nonindex = true ;
1837
- }
1838
- }
1839
- Res :: Local ( local_id) =>
1840
- {
1841
-
1842
- if local_id == self . var {
1843
- self . nonindex = true ;
1844
- } else {
1845
- // not the correct variable, but still a variable
1846
- self . referenced. insert( path. segments[ 0 ] . ident. name) ;
1847
- }
1841
+ if let Res :: Local ( local_id) = self . cx. tables. qpath_res( qpath, expr. hir_id) {
1842
+ if local_id == self . var {
1843
+ self . nonindex = true ;
1844
+ } else {
1845
+ // not the correct variable, but still a variable
1846
+ self . referenced. insert( path. segments[ 0 ] . ident. name) ;
1848
1847
}
1849
- _ => { }
1850
1848
}
1851
1849
}
1852
1850
}
@@ -2378,7 +2376,7 @@ impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> {
2378
2376
let res = self . cx. tables. qpath_res( qpath, ex. hir_id) ;
2379
2377
then {
2380
2378
match res {
2381
- Res :: Local ( node_id) | Res :: Upvar ( node_id , .. ) => {
2379
+ Res :: Local ( node_id) => {
2382
2380
self . ids. insert( node_id) ;
2383
2381
} ,
2384
2382
Res :: Def ( DefKind :: Static , def_id) => {
0 commit comments