@@ -1756,7 +1756,7 @@ fn lint_expect_fun_call(
1756
1756
&& {
1757
1757
let arg_type = cx. tables . expr_ty ( & call_args[ 0 ] ) ;
1758
1758
let base_type = walk_ptrs_ty ( arg_type) ;
1759
- base_type. kind == ty:: Str || match_type ( cx, base_type, & paths :: STRING )
1759
+ base_type. kind == ty:: Str || is_type_diagnostic_item ( cx, base_type, sym ! ( string_type ) )
1760
1760
}
1761
1761
{
1762
1762
& call_args[ 0 ]
@@ -1774,7 +1774,7 @@ fn lint_expect_fun_call(
1774
1774
// converted to string.
1775
1775
fn requires_to_string ( cx : & LateContext < ' _ , ' _ > , arg : & hir:: Expr < ' _ > ) -> bool {
1776
1776
let arg_ty = cx. tables . expr_ty ( arg) ;
1777
- if match_type ( cx, arg_ty, & paths :: STRING ) {
1777
+ if is_type_diagnostic_item ( cx, arg_ty, sym ! ( string_type ) ) {
1778
1778
return false ;
1779
1779
}
1780
1780
if let ty:: Ref ( _, ty, ..) = arg_ty. kind {
@@ -2054,7 +2054,7 @@ fn lint_string_extend(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, args: &[hi
2054
2054
let self_ty = walk_ptrs_ty ( cx. tables . expr_ty ( target) ) ;
2055
2055
let ref_str = if self_ty. kind == ty:: Str {
2056
2056
""
2057
- } else if match_type ( cx, self_ty, & paths :: STRING ) {
2057
+ } else if is_type_diagnostic_item ( cx, self_ty, sym ! ( string_type ) ) {
2058
2058
"&"
2059
2059
} else {
2060
2060
return ;
@@ -2080,7 +2080,7 @@ fn lint_string_extend(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, args: &[hi
2080
2080
2081
2081
fn lint_extend ( cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr < ' _ > , args : & [ hir:: Expr < ' _ > ] ) {
2082
2082
let obj_ty = walk_ptrs_ty ( cx. tables . expr_ty ( & args[ 0 ] ) ) ;
2083
- if match_type ( cx, obj_ty, & paths :: STRING ) {
2083
+ if is_type_diagnostic_item ( cx, obj_ty, sym ! ( string_type ) ) {
2084
2084
lint_string_extend ( cx, expr, args) ;
2085
2085
}
2086
2086
}
@@ -2242,7 +2242,7 @@ fn lint_iter_nth<'a, 'tcx>(
2242
2242
"slice"
2243
2243
} else if is_type_diagnostic_item ( cx, cx. tables . expr_ty ( & iter_args[ 0 ] ) , sym ! ( vec_type) ) {
2244
2244
"Vec"
2245
- } else if match_type ( cx, cx. tables . expr_ty ( & iter_args[ 0 ] ) , & paths :: VEC_DEQUE ) {
2245
+ } else if is_type_diagnostic_item ( cx, cx. tables . expr_ty ( & iter_args[ 0 ] ) , sym ! ( vecdeque_type ) ) {
2246
2246
"VecDeque"
2247
2247
} else {
2248
2248
let nth_args = nth_and_iter_args[ 0 ] ;
@@ -2301,10 +2301,10 @@ fn lint_get_unwrap<'a, 'tcx>(
2301
2301
} else if is_type_diagnostic_item ( cx, expr_ty, sym ! ( vec_type) ) {
2302
2302
needs_ref = get_args_str. parse :: < usize > ( ) . is_ok ( ) ;
2303
2303
"Vec"
2304
- } else if match_type ( cx, expr_ty, & paths :: VEC_DEQUE ) {
2304
+ } else if is_type_diagnostic_item ( cx, expr_ty, sym ! ( vecdeque_type ) ) {
2305
2305
needs_ref = get_args_str. parse :: < usize > ( ) . is_ok ( ) ;
2306
2306
"VecDeque"
2307
- } else if !is_mut && match_type ( cx, expr_ty, & paths :: HASHMAP ) {
2307
+ } else if !is_mut && is_type_diagnostic_item ( cx, expr_ty, sym ! ( hashmap_type ) ) {
2308
2308
needs_ref = true ;
2309
2309
"HashMap"
2310
2310
} else if !is_mut && match_type ( cx, expr_ty, & paths:: BTREEMAP ) {
@@ -2510,7 +2510,7 @@ fn lint_map_flatten<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr<
2510
2510
}
2511
2511
2512
2512
// lint if caller of `.map().flatten()` is an Option
2513
- if match_type ( cx, cx. tables . expr_ty ( & map_args[ 0 ] ) , & paths :: OPTION ) {
2513
+ if is_type_diagnostic_item ( cx, cx. tables . expr_ty ( & map_args[ 0 ] ) , sym ! ( option_type ) ) {
2514
2514
let msg = "called `map(..).flatten()` on an `Option`. \
2515
2515
This is more succinctly expressed by calling `.and_then(..)`";
2516
2516
let self_snippet = snippet ( cx, map_args[ 0 ] . span , ".." ) ;
@@ -2678,7 +2678,7 @@ fn lint_option_and_then_some(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, arg
2678
2678
const NO_OP_MSG : & str = "using `Option.and_then(Some)`, which is a no-op" ;
2679
2679
2680
2680
let ty = cx. tables . expr_ty ( & args[ 0 ] ) ;
2681
- if !match_type ( cx, ty, & paths :: OPTION ) {
2681
+ if !is_type_diagnostic_item ( cx, ty, sym ! ( option_type ) ) {
2682
2682
return ;
2683
2683
}
2684
2684
@@ -3282,7 +3282,7 @@ fn lint_option_as_ref_deref<'a, 'tcx>(
3282
3282
let same_mutability = |m| ( is_mut && m == & hir:: Mutability :: Mut ) || ( !is_mut && m == & hir:: Mutability :: Not ) ;
3283
3283
3284
3284
let option_ty = cx. tables . expr_ty ( & as_ref_args[ 0 ] ) ;
3285
- if !match_type ( cx, option_ty, & paths :: OPTION ) {
3285
+ if !is_type_diagnostic_item ( cx, option_ty, sym ! ( option_type ) ) {
3286
3286
return ;
3287
3287
}
3288
3288
0 commit comments