about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamelid <camelidcamel@gmail.com>2020-10-18 17:37:26 -0700
committerCamelid <camelidcamel@gmail.com>2020-10-18 17:38:47 -0700
commit3eab21e22d080562dbe85ef440309c03c07becba (patch)
tree46f3e40a7ffcaf6bde2e87c71a159e63020126aa
parent8a6831a7fd3fc624643b50f494212e0ceaad3c28 (diff)
downloadrust-3eab21e22d080562dbe85ef440309c03c07becba.tar.gz
rust-3eab21e22d080562dbe85ef440309c03c07becba.zip
Don't ICE if called with a `TyKind::Error`
It felt too harsh to estebank and others to ICE even though it's
technically a mistake to show a `TyKind::Error`.
-rw-r--r--compiler/rustc_middle/src/ty/sty.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs
index 9e60253106b..e049341659c 100644
--- a/compiler/rustc_middle/src/ty/sty.rs
+++ b/compiler/rustc_middle/src/ty/sty.rs
@@ -212,13 +212,13 @@ impl TyKind<'tcx> {
     }
 
     /// Get the article ("a" or "an") to use with this type.
-    ///
-    /// **Panics if `self` is [`TyKind::Error`].**
     pub fn article(&self) -> &'static str {
         match self {
             Int(_) | Float(_) | Array(_, _) => "an",
             Adt(def, _) if def.is_enum() => "an",
-            Error(_) => panic!(),
+            // This should never happen, but ICEing and causing the user's code
+            // to not compile felt too harsh.
+            Error(_) => "a",
             _ => "a",
         }
     }