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`.
This commit is contained in:
Camelid 2020-10-18 17:37:26 -07:00
parent 8a6831a7fd
commit 3eab21e22d

View File

@ -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",
}
}