Remove Sugar enum and inline single variant into CalledVia

This commit is contained in:
ayazhafiz 2021-11-18 21:23:41 -05:00
parent 4ef40be0f0
commit 5bfc52cd3b
3 changed files with 6 additions and 11 deletions

View file

@ -10,7 +10,7 @@ use crate::pattern::{canonicalize_pattern, Pattern};
use crate::procedure::References;
use crate::scope::Scope;
use roc_collections::all::{ImSet, MutMap, MutSet, SendMap};
use roc_module::called_via::{CalledVia, Sugar};
use roc_module::called_via::CalledVia;
use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
use roc_module::low_level::LowLevel;
use roc_module::symbol::Symbol;
@ -1711,7 +1711,7 @@ fn desugar_str_segments(var_store: &mut VarStore, segments: Vec<StrSegment>) ->
(var_store.fresh(), loc_new_expr),
(var_store.fresh(), loc_expr),
],
CalledVia::Sugar(Sugar::StringInterpolation),
CalledVia::StringInterpolation,
);
loc_expr = Located::new(0, 0, 0, 0, expr);

View file

@ -13,13 +13,8 @@ pub enum CalledVia {
/// Calling with a unary operator, e.g. (!foo bar baz) or (-foo bar baz)
UnaryOp(UnaryOp),
/// This call is the result of some desugaring, e.g. "\(first) \(last)" is
/// transformed into first ++ last.
Sugar(Sugar),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Sugar {
/// This call is the result of desugaring string interpolation,
/// e.g. "\(first) \(last)" is transformed into Str.concat (Str.concat first " ") last.
StringInterpolation,
}

View file

@ -1,6 +1,6 @@
use roc_can::expected::{Expected, PExpected};
use roc_collections::all::{Index, MutSet, SendMap};
use roc_module::called_via::{BinOp, CalledVia, Sugar};
use roc_module::called_via::{BinOp, CalledVia};
use roc_module::ident::{Ident, IdentStr, Lowercase, TagName};
use roc_module::symbol::Symbol;
use roc_region::all::{Located, Region};
@ -1055,7 +1055,7 @@ fn add_category<'b>(
| BinOp::GreaterThanOrEq,
),
) => alloc.concat(vec![alloc.text("This comparison produces:")]),
CallResult(Some(_), CalledVia::Sugar(Sugar::StringInterpolation)) => {
CallResult(Some(_), CalledVia::StringInterpolation) => {
alloc.concat(vec![alloc.text("This string interpolation produces:")])
}
CallResult(Some(symbol), _) => alloc.concat(vec![