@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
2
2
use clippy_utils:: source:: snippet_with_applicability;
3
3
use clippy_utils:: sugg:: Sugg ;
4
4
use clippy_utils:: ty:: is_type_diagnostic_item;
5
- use clippy_utils:: { any_parent_has_attr , can_mut_borrow_both, differing_macro_contexts, eq_expr_value} ;
5
+ use clippy_utils:: { can_mut_borrow_both, differing_macro_contexts, eq_expr_value, is_no_core_crate , is_no_std_crate } ;
6
6
use if_chain:: if_chain;
7
7
use rustc_errors:: Applicability ;
8
8
use rustc_hir:: { BinOpKind , Block , Expr , ExprKind , PatKind , QPath , Stmt , StmtKind } ;
@@ -113,9 +113,9 @@ fn generate_swap_warning(cx: &LateContext<'_>, e1: &Expr<'_>, e2: &Expr<'_>, spa
113
113
114
114
let first = Sugg :: hir_with_applicability ( cx, e1, ".." , & mut applicability) ;
115
115
let second = Sugg :: hir_with_applicability ( cx, e2, ".." , & mut applicability) ;
116
- let sugg = if !any_parent_has_attr ( cx. tcx , e1 . hir_id , sym :: no_std ) {
116
+ let sugg = if !is_no_std_crate ( cx) {
117
117
"std"
118
- } else if any_parent_has_attr ( cx. tcx , e1 . hir_id , sym :: no_core ) {
118
+ } else if is_no_core_crate ( cx) {
119
119
""
120
120
} else {
121
121
"core"
@@ -199,9 +199,9 @@ fn check_suspicious_swap(cx: &LateContext<'_>, block: &Block<'_>) {
199
199
} ;
200
200
201
201
let span = first. span. to( second. span) ;
202
- let sugg = if !any_parent_has_attr ( cx. tcx , block . hir_id , sym :: no_std ) {
202
+ let sugg = if !is_no_std_crate ( cx) {
203
203
"std"
204
- } else if any_parent_has_attr ( cx. tcx , block . hir_id , sym :: no_core ) {
204
+ } else if is_no_core_crate ( cx) {
205
205
""
206
206
} else {
207
207
"core"
0 commit comments