From 3eab21e22d080562dbe85ef440309c03c07becba Mon Sep 17 00:00:00 2001 From: Camelid Date: Sun, 18 Oct 2020 17:37:26 -0700 Subject: [PATCH] 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`. --- compiler/rustc_middle/src/ty/sty.rs | 6 +++--- 1 file 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", } }