Special-case 2-branch if/else errors

This commit is contained in:
Richard Feldman 2020-04-03 01:51:42 -04:00
parent dc3e2d307c
commit 98f4f46248
6 changed files with 158 additions and 75 deletions

View file

@ -171,8 +171,11 @@ pub enum ReportText {
/// Emphasized text (might be bold, italics, a different color, etc)
EmText(Box<str>),
/// Text rendered as code (e.g. a monospace font, or with backticks around it).
Code(Box<str>),
/// A global tag rendered as code (e.g. a monospace font, or with backticks around it).
GlobalTag(Box<str>),
/// A language keyword like `if`, rendered as code (e.g. a monospace font, or with backticks around it).
Keyword(Box<str>),
/// A region in the original source
Region(roc_region::all::Region),
@ -202,8 +205,12 @@ pub fn em_text(str: &str) -> ReportText {
ReportText::EmText(Box::from(str))
}
pub fn code_text(str: &str) -> ReportText {
ReportText::Code(Box::from(str))
pub fn global_tag_text(str: &str) -> ReportText {
ReportText::GlobalTag(Box::from(str))
}
pub fn keyword_text(str: &str) -> ReportText {
ReportText::Keyword(Box::from(str))
}
pub fn url(str: &str) -> ReportText {
@ -310,7 +317,7 @@ impl ReportText {
buf.push_str(&string);
buf.push('*');
}
Code(string) => {
GlobalTag(string) | Keyword(string) => {
// Since this is CI, the best we can do for code text is backticks.
buf.push('`');
buf.push_str(&string);