diff options
| author | Konrad Borowski <konrad@borowski.pw> | 2018-12-30 13:40:27 +0100 |
|---|---|---|
| committer | Konrad Borowski <konrad@borowski.pw> | 2018-12-30 13:40:27 +0100 |
| commit | 978e3ac2cfac8cb62147d2ed6992cbcbf37bb45f (patch) | |
| tree | f5fc499e1d590d572d92c39ed9a4b92c1ddecd2e | |
| parent | 1130bbc26f849c81131c4ac336ec80c319d20769 (diff) | |
| download | rust-978e3ac2cfac8cb62147d2ed6992cbcbf37bb45f.tar.gz rust-978e3ac2cfac8cb62147d2ed6992cbcbf37bb45f.zip | |
Use node_id_to_type_opt instead of node_it_to_type in random_state
| -rw-r--r-- | clippy_lints/src/random_state.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clippy_lints/src/random_state.rs b/clippy_lints/src/random_state.rs index 02abd2e93bd..f95116c04b6 100644 --- a/clippy_lints/src/random_state.rs +++ b/clippy_lints/src/random_state.rs @@ -35,11 +35,13 @@ impl LintPass for Pass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_ty(&mut self, cx: &LateContext<'a, 'tcx>, ty: &Ty) { - if let TyKind::Adt(_, substs) = cx.tables.node_id_to_type(ty.hir_id).sty { - for subst in substs { - if let UnpackedKind::Type(build_hasher) = subst.unpack() { - if match_type(cx, build_hasher, &paths::RANDOM_STATE) { - span_lint(cx, RANDOM_STATE, ty.span, "usage of RandomState"); + if let Some(tys) = cx.tables.node_id_to_type_opt(ty.hir_id) { + if let TyKind::Adt(_, substs) = tys.sty { + for subst in substs { + if let UnpackedKind::Type(build_hasher) = subst.unpack() { + if match_type(cx, build_hasher, &paths::RANDOM_STATE) { + span_lint(cx, RANDOM_STATE, ty.span, "usage of RandomState"); + } } } } |
