@@ -330,8 +330,7 @@ pub fn is_trait_method(cx: &LateContext<'_>, expr: &Expr<'_>, diag_item: Symbol)
330
330
331
331
/// Checks if the `def_id` belongs to a function that is part of a trait impl.
332
332
pub fn is_def_id_trait_method ( cx : & LateContext < ' _ > , def_id : LocalDefId ) -> bool {
333
- if let Some ( hir_id) = cx. tcx . opt_local_def_id_to_hir_id ( def_id)
334
- && let Node :: Item ( item) = cx. tcx . parent_hir_node ( hir_id)
333
+ if let Node :: Item ( item) = cx. tcx . parent_hir_node ( cx. tcx . local_def_id_to_hir_id ( def_id) )
335
334
&& let ItemKind :: Impl ( imp) = item. kind
336
335
{
337
336
imp. of_trait . is_some ( )
@@ -574,12 +573,12 @@ fn local_item_children_by_name(tcx: TyCtxt<'_>, local_id: LocalDefId, name: Symb
574
573
let hir = tcx. hir ( ) ;
575
574
576
575
let root_mod;
577
- let item_kind = match tcx. opt_hir_node_by_def_id ( local_id) {
578
- Some ( Node :: Crate ( r#mod) ) => {
576
+ let item_kind = match tcx. hir_node_by_def_id ( local_id) {
577
+ Node :: Crate ( r#mod) => {
579
578
root_mod = ItemKind :: Mod ( r#mod) ;
580
579
& root_mod
581
580
} ,
582
- Some ( Node :: Item ( item) ) => & item. kind ,
581
+ Node :: Item ( item) => & item. kind ,
583
582
_ => return Vec :: new ( ) ,
584
583
} ;
585
584
@@ -1254,12 +1253,10 @@ pub fn is_in_panic_handler(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
1254
1253
/// Gets the name of the item the expression is in, if available.
1255
1254
pub fn get_item_name ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> Option < Symbol > {
1256
1255
let parent_id = cx. tcx . hir ( ) . get_parent_item ( expr. hir_id ) . def_id ;
1257
- match cx. tcx . opt_hir_node_by_def_id ( parent_id) {
1258
- Some (
1259
- Node :: Item ( Item { ident, .. } )
1260
- | Node :: TraitItem ( TraitItem { ident, .. } )
1261
- | Node :: ImplItem ( ImplItem { ident, .. } ) ,
1262
- ) => Some ( ident. name ) ,
1256
+ match cx. tcx . hir_node_by_def_id ( parent_id) {
1257
+ Node :: Item ( Item { ident, .. } )
1258
+ | Node :: TraitItem ( TraitItem { ident, .. } )
1259
+ | Node :: ImplItem ( ImplItem { ident, .. } ) => Some ( ident. name ) ,
1263
1260
_ => None ,
1264
1261
}
1265
1262
}
@@ -2667,11 +2664,10 @@ impl<'tcx> ExprUseNode<'tcx> {
2667
2664
. and ( Binder :: dummy ( cx. tcx . type_of ( id) . instantiate_identity ( ) ) ) ,
2668
2665
) ) ,
2669
2666
Self :: Return ( id) => {
2670
- let hir_id = cx. tcx . local_def_id_to_hir_id ( id. def_id ) ;
2671
2667
if let Node :: Expr ( Expr {
2672
2668
kind : ExprKind :: Closure ( c) ,
2673
2669
..
2674
- } ) = cx. tcx . hir_node ( hir_id )
2670
+ } ) = cx. tcx . hir_node_by_def_id ( id . def_id )
2675
2671
{
2676
2672
match c. fn_decl . output {
2677
2673
FnRetTy :: DefaultReturn ( _) => None ,
0 commit comments