about summary refs log tree commit diff
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2019-03-19 22:46:45 +0100
committerflip1995 <hello@philkrones.com>2019-04-03 18:22:19 +0200
commit5a788f0ff7c8bbc83dc1cb6db58194ff5759b881 (patch)
tree5b9229a34bb4a921825895a7ae4618398988dc20
parent9b2bf7085133f916219a357c78c7b8c75a3269ba (diff)
downloadrust-5a788f0ff7c8bbc83dc1cb6db58194ff5759b881.tar.gz
rust-5a788f0ff7c8bbc83dc1cb6db58194ff5759b881.zip
Fix bug in TyKind lint
-rw-r--r--src/librustc/lint/internal.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/librustc/lint/internal.rs b/src/librustc/lint/internal.rs
index 7d820764549..3ae07968296 100644
--- a/src/librustc/lint/internal.rs
+++ b/src/librustc/lint/internal.rs
@@ -1,7 +1,7 @@
 //! Some lints that are only useful in the compiler or crates that use compiler internals, such as
 //! Clippy.
 
-use crate::hir::{HirId, Path, QPath, Ty, TyKind};
+use crate::hir::{def::Def, HirId, Path, QPath, Ty, TyKind};
 use crate::lint::{
     EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintArray, LintContext, LintPass,
 };
@@ -92,10 +92,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyKindUsage {
                     segments: segments_iter.cloned().collect(),
                 };
 
-                if let Some(def) = last.def {
-                    if def
-                        .def_id()
-                        .match_path(cx.tcx, &["rustc", "ty", "sty", "TyKind"])
+                match last.def {
+                    Some(Def::Err) => (),
+                    Some(def)
+                        if def
+                            .def_id()
+                            .match_path(cx.tcx, &["rustc", "ty", "sty", "TyKind"]) =>
                     {
                         cx.struct_span_lint(
                             USAGE_OF_TY_TYKIND,
@@ -110,6 +112,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyKindUsage {
                         )
                         .emit();
                     }
+                    _ => (),
                 }
             }
         }