1
1
use crate :: reexport:: * ;
2
2
use if_chain:: if_chain;
3
3
use itertools:: Itertools ;
4
- use rustc:: hir:: def:: Def ;
4
+ use rustc:: hir:: def:: { DefKind , Res } ;
5
5
use rustc:: hir:: def_id;
6
6
use rustc:: hir:: intravisit:: { walk_block, walk_expr, walk_pat, walk_stmt, NestedVisitorMap , Visitor } ;
7
7
use rustc:: hir:: * ;
@@ -778,7 +778,7 @@ fn same_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: HirId) -> bo
778
778
if let ExprKind :: Path ( ref qpath) = expr. node;
779
779
if let QPath :: Resolved ( None , ref path) = * qpath;
780
780
if path. segments. len( ) == 1 ;
781
- if let Def :: Local ( local_id) = cx. tables. qpath_def ( qpath, expr. hir_id) ;
781
+ if let Res :: Local ( local_id) = cx. tables. qpath_res ( qpath, expr. hir_id) ;
782
782
// our variable!
783
783
if local_id == var;
784
784
then {
@@ -1637,8 +1637,8 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<HirId>
1637
1637
if let ExprKind :: Path ( ref qpath) = bound. node;
1638
1638
if let QPath :: Resolved ( None , _) = * qpath;
1639
1639
then {
1640
- let def = cx. tables. qpath_def ( qpath, bound. hir_id) ;
1641
- if let Def :: Local ( node_id) = def {
1640
+ let res = cx. tables. qpath_res ( qpath, bound. hir_id) ;
1641
+ if let Res :: Local ( node_id) = res {
1642
1642
let node_str = cx. tcx. hir( ) . get_by_hir_id( node_id) ;
1643
1643
if_chain! {
1644
1644
if let Node :: Binding ( pat) = node_str;
@@ -1772,9 +1772,9 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
1772
1772
if self . prefer_mutable {
1773
1773
self . indexed_mut. insert( seqvar. segments[ 0 ] . ident. name) ;
1774
1774
}
1775
- let def = self . cx. tables. qpath_def ( seqpath, seqexpr. hir_id) ;
1776
- match def {
1777
- Def :: Local ( hir_id) | Def :: Upvar ( hir_id, ..) => {
1775
+ let res = self . cx. tables. qpath_res ( seqpath, seqexpr. hir_id) ;
1776
+ match res {
1777
+ Res :: Local ( hir_id) | Res :: Upvar ( hir_id, ..) => {
1778
1778
let parent_id = self . cx. tcx. hir( ) . get_parent_item( expr. hir_id) ;
1779
1779
let parent_def_id = self . cx. tcx. hir( ) . local_def_id_from_hir_id( parent_id) ;
1780
1780
let extent = self . cx. tcx. region_scope_tree( parent_def_id) . var_scope( hir_id. local_id) ;
@@ -1789,7 +1789,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
1789
1789
}
1790
1790
return false ; // no need to walk further *on the variable*
1791
1791
}
1792
- Def :: Static ( ..) | Def :: Const ( ..) => {
1792
+ Res :: Def ( DefKind :: Static , ..) | Res :: Def ( DefKind :: Const , ..) => {
1793
1793
if indexed_indirectly {
1794
1794
self . indexed_indirectly. insert( seqvar. segments[ 0 ] . ident. name, None ) ;
1795
1795
}
@@ -1834,14 +1834,14 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
1834
1834
if let QPath :: Resolved ( None , ref path) = * qpath;
1835
1835
if path. segments. len( ) == 1 ;
1836
1836
then {
1837
- match self . cx. tables. qpath_def ( qpath, expr. hir_id) {
1838
- Def :: Upvar ( local_id, ..) => {
1837
+ match self . cx. tables. qpath_res ( qpath, expr. hir_id) {
1838
+ Res :: Upvar ( local_id, ..) => {
1839
1839
if local_id == self . var {
1840
1840
// we are not indexing anything, record that
1841
1841
self . nonindex = true ;
1842
1842
}
1843
1843
}
1844
- Def :: Local ( local_id) =>
1844
+ Res :: Local ( local_id) =>
1845
1845
{
1846
1846
1847
1847
if local_id == self . var {
@@ -2187,8 +2187,8 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
2187
2187
2188
2188
fn var_def_id ( cx : & LateContext < ' _ , ' _ > , expr : & Expr ) -> Option < HirId > {
2189
2189
if let ExprKind :: Path ( ref qpath) = expr. node {
2190
- let path_res = cx. tables . qpath_def ( qpath, expr. hir_id ) ;
2191
- if let Def :: Local ( node_id) = path_res {
2190
+ let path_res = cx. tables . qpath_res ( qpath, expr. hir_id ) ;
2191
+ if let Res :: Local ( node_id) = path_res {
2192
2192
return Some ( node_id) ;
2193
2193
}
2194
2194
}
@@ -2380,13 +2380,13 @@ impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> {
2380
2380
if_chain ! {
2381
2381
if let ExprKind :: Path ( ref qpath) = ex. node;
2382
2382
if let QPath :: Resolved ( None , _) = * qpath;
2383
- let def = self . cx. tables. qpath_def ( qpath, ex. hir_id) ;
2383
+ let res = self . cx. tables. qpath_res ( qpath, ex. hir_id) ;
2384
2384
then {
2385
- match def {
2386
- Def :: Local ( node_id) | Def :: Upvar ( node_id, ..) => {
2385
+ match res {
2386
+ Res :: Local ( node_id) | Res :: Upvar ( node_id, ..) => {
2387
2387
self . ids. insert( node_id) ;
2388
2388
} ,
2389
- Def :: Static ( def_id) => {
2389
+ Res :: Def ( DefKind :: Static , def_id) => {
2390
2390
let mutable = self . cx. tcx. is_mutable_static( def_id) ;
2391
2391
self . def_ids. insert( def_id, mutable) ;
2392
2392
} ,
0 commit comments