diff --git a/compiler/types/src/subs.rs b/compiler/types/src/subs.rs index 4aca1a9eb5..6625ab0630 100644 --- a/compiler/types/src/subs.rs +++ b/compiler/types/src/subs.rs @@ -327,6 +327,14 @@ fn subs_fmt_desc(this: &Descriptor, subs: &Subs, f: &mut fmt::Formatter) -> fmt: write!(f, " m: {:?}", &this.mark) } +pub struct SubsFmtContent<'a>(pub &'a Content, pub &'a Subs); + +impl<'a> fmt::Debug for SubsFmtContent<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + subs_fmt_content(self.0, self.1, f) + } +} + fn subs_fmt_content(this: &Content, subs: &Subs, f: &mut fmt::Formatter) -> fmt::Result { match this { Content::FlexVar(name) => write!(f, "Flex({:?})", name), @@ -345,6 +353,14 @@ fn subs_fmt_content(this: &Content, subs: &Subs, f: &mut fmt::Formatter) -> fmt: } } +pub struct SubsFmtFlatType<'a>(pub &'a FlatType, pub &'a Subs); + +impl<'a> fmt::Debug for SubsFmtFlatType<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + subs_fmt_flat_type(self.0, self.1, f) + } +} + fn subs_fmt_flat_type(this: &FlatType, subs: &Subs, f: &mut fmt::Formatter) -> fmt::Result { match this { FlatType::Apply(name, arguments) => { diff --git a/compiler/unify/src/unify.rs b/compiler/unify/src/unify.rs index 169559476d..51771efe07 100644 --- a/compiler/unify/src/unify.rs +++ b/compiler/unify/src/unify.rs @@ -1076,8 +1076,8 @@ fn unify_flat_type( // any other combination is a mismatch mismatch!( "Trying to unify two flat types that are incompatible: {:?} ~ {:?}", - other1, - other2 + roc_types::subs::SubsFmtFlatType(other1, subs), + roc_types::subs::SubsFmtFlatType(other2, subs) ) } }