Skip to content

Commit

Permalink
Don't ICE if called with a TyKind::Error
Browse files Browse the repository at this point in the history
It felt too harsh to estebank and others to ICE even though it's
technically a mistake to show a `TyKind::Error`.
  • Loading branch information
camelid committed Oct 19, 2020
1 parent 8a6831a commit 3eab21e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}
Expand Down

0 comments on commit 3eab21e

Please sign in to comment.