diff --git a/compiler/can/src/exhaustive.rs b/compiler/can/src/exhaustive.rs index e69f445cfd..235e347772 100644 --- a/compiler/can/src/exhaustive.rs +++ b/compiler/can/src/exhaustive.rs @@ -10,6 +10,9 @@ use roc_types::types::AliasKind; pub use roc_exhaustive::Context as ExhaustiveContext; +pub const GUARD_CTOR: &'static str = "#Guard"; +pub const NONEXHAUSIVE_CTOR: &'static str = "#Open"; + pub fn check( subs: &Subs, sketched_rows: SketchedRows, @@ -215,7 +218,7 @@ pub fn sketch_rows(target_var: Variable, region: Region, patterns: &[WhenBranch] render_as: RenderAs::Guard, alternatives: vec![Ctor { tag_id, - name: TagName::Global("#Guard".into()), + name: TagName::Global(GUARD_CTOR.into()), arity: 2, }], }; @@ -298,7 +301,7 @@ fn convert_tag(subs: &Subs, whole_var: Variable, this_tag: &TagName) -> (Union, // be matched unless there's an `Anything` pattern. let opt_openness_tag = match subs.get_content_without_compacting(ext) { FlexVar(_) | RigidVar(_) => { - let openness_tag = TagName::Global("#Open".into()); + let openness_tag = TagName::Global(NONEXHAUSIVE_CTOR.into()); num_tags += 1; Some((openness_tag, &[] as _)) } diff --git a/compiler/types/src/subs.rs b/compiler/types/src/subs.rs index f9c129693a..1d9a181c67 100644 --- a/compiler/types/src/subs.rs +++ b/compiler/types/src/subs.rs @@ -2118,18 +2118,6 @@ impl Content { self } - - pub fn unroll_structural_alias<'a>(&'a self, subs: &'a Subs) -> &'a Self { - let mut result = self; - loop { - match result { - Self::Alias(_, _, real_var, AliasKind::Structural) => { - result = subs.get_content_without_compacting(*real_var) - } - _ => return result, - } - } - } } #[derive(Clone, Copy, Debug)] diff --git a/reporting/src/error/type.rs b/reporting/src/error/type.rs index d52f69bfdc..3d1d6f58d6 100644 --- a/reporting/src/error/type.rs +++ b/reporting/src/error/type.rs @@ -3632,6 +3632,7 @@ fn pattern_to_doc_help<'b>( pattern: roc_exhaustive::Pattern, in_type_param: bool, ) -> RocDocBuilder<'b> { + use roc_can::exhaustive::{GUARD_CTOR, NONEXHAUSIVE_CTOR}; use roc_exhaustive::Literal::*; use roc_exhaustive::Pattern::*; use roc_exhaustive::RenderAs; @@ -3654,7 +3655,7 @@ fn pattern_to_doc_help<'b>( // #Guard debug_assert_eq!( union.alternatives[tag_id.0 as usize].name, - TagName::Global("#Guard".into()) + TagName::Global(GUARD_CTOR.into()) ); debug_assert!(args.len() == 2); let tag = pattern_to_doc_help(alloc, args[1].clone(), in_type_param); @@ -3693,7 +3694,7 @@ fn pattern_to_doc_help<'b>( RenderAs::Tag | RenderAs::Opaque => { let tag = &union.alternatives[tag_id.0 as usize]; match &tag.name { - TagName::Global(name) if name.as_str() == "#Open" => { + TagName::Global(name) if name.as_str() == NONEXHAUSIVE_CTOR => { return pattern_to_doc_help( alloc, roc_exhaustive::Pattern::Anything,