Skip to content

Commit 978e3ac

Browse files
committed
Use node_id_to_type_opt instead of node_it_to_type in random_state
1 parent 1130bbc commit 978e3ac

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

clippy_lints/src/random_state.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ impl LintPass for Pass {
3535

3636
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
3737
fn check_ty(&mut self, cx: &LateContext<'a, 'tcx>, ty: &Ty) {
38-
if let TyKind::Adt(_, substs) = cx.tables.node_id_to_type(ty.hir_id).sty {
39-
for subst in substs {
40-
if let UnpackedKind::Type(build_hasher) = subst.unpack() {
41-
if match_type(cx, build_hasher, &paths::RANDOM_STATE) {
42-
span_lint(cx, RANDOM_STATE, ty.span, "usage of RandomState");
38+
if let Some(tys) = cx.tables.node_id_to_type_opt(ty.hir_id) {
39+
if let TyKind::Adt(_, substs) = tys.sty {
40+
for subst in substs {
41+
if let UnpackedKind::Type(build_hasher) = subst.unpack() {
42+
if match_type(cx, build_hasher, &paths::RANDOM_STATE) {
43+
span_lint(cx, RANDOM_STATE, ty.span, "usage of RandomState");
44+
}
4345
}
4446
}
4547
}

0 commit comments

Comments
 (0)