Skip to content

Commit 31a4a32

Browse files
committed
Don't use TyKind directly, use ty instead
1 parent 9ceece9 commit 31a4a32

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

clippy_lints/src/collect.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use itertools::{repeat_n, Itertools};
2-
use rustc::hir::*;
3-
use rustc::ty::{AssociatedKind, TyKind};
2+
use rustc::hir::{Expr, Stmt, DeclKind, StmtKind, ExprKind};
3+
use rustc::ty::{AssociatedKind};
44
use syntax::ast::NodeId;
55

66
use std::collections::HashSet;
@@ -9,7 +9,8 @@ use crate::rustc_errors::Applicability;
99
use crate::rustc::lint::{
1010
LateContext, LateLintPass, LintArray, LintPass,
1111
};
12-
use crate::rustc::{declare_tool_lint, lint_array};
12+
use crate::rustc::ty::Ty;
13+
use crate::rustc::{declare_tool_lint, lint_array, ty};
1314
use crate::utils::{match_trait_method, match_type, span_lint_and_sugg};
1415
use crate::utils::paths;
1516

@@ -75,11 +76,11 @@ struct Suggestion {
7576

7677
fn format_suggestion_pattern<'a, 'tcx>(
7778
cx: &LateContext<'a, 'tcx>,
78-
collection_ty: &TyKind<'_>,
79+
collection_ty: &Ty<'_>,
7980
is_option: bool,
8081
) -> String {
81-
let collection_pat = match collection_ty {
82-
TyKind::Adt(def, subs) => {
82+
let collection_pat = match collection_ty.sty {
83+
ty::Adt(def, subs) => {
8384
let mut buf = cx.tcx.item_path_str(def.did);
8485

8586
if !subs.is_empty() {
@@ -90,7 +91,7 @@ fn format_suggestion_pattern<'a, 'tcx>(
9091

9192
buf
9293
},
93-
TyKind::Param(p) => p.to_string(),
94+
ty::Param(p) => p.to_string(),
9495
_ => "_".into(),
9596
};
9697

@@ -131,13 +132,13 @@ fn check_expr_for_collect<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr
131132

132133
return if match_type(cx, normal_ty, &paths::OPTION) {
133134
Some(Suggestion {
134-
pattern: format_suggestion_pattern(cx, &collect_ty.sty.clone(), true),
135+
pattern: format_suggestion_pattern(cx, &collect_ty, true),
135136
type_colloquial: "Option",
136137
success_variant: "Some",
137138
})
138139
} else if match_type(cx, normal_ty, &paths::RESULT) {
139140
Some(Suggestion {
140-
pattern: format_suggestion_pattern(cx, &collect_ty.sty.clone(), false),
141+
pattern: format_suggestion_pattern(cx, &collect_ty, false),
141142
type_colloquial: "Result",
142143
success_variant: "Ok",
143144
})

0 commit comments

Comments
 (0)