Remove private tag variants

This commit is contained in:
Ayaz Hafiz 2022-04-25 11:38:54 -04:00
parent 37b9a34448
commit cf8409dfaa
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
13 changed files with 76 additions and 108 deletions

View file

@ -2,7 +2,10 @@
//! http://moscova.inria.fr/~maranget/papers/warn/warn.pdf //! http://moscova.inria.fr/~maranget/papers/warn/warn.pdf
use roc_collections::all::{HumanIndex, MutMap}; use roc_collections::all::{HumanIndex, MutMap};
use roc_module::ident::{Lowercase, TagIdIntType, TagName}; use roc_module::{
ident::{Lowercase, TagIdIntType, TagName},
symbol::Symbol,
};
use roc_region::all::Region; use roc_region::all::Region;
use roc_std::RocDec; use roc_std::RocDec;
@ -15,9 +18,9 @@ pub struct Union {
} }
impl Union { impl Union {
pub fn newtype_wrapper(tag_name: TagName, arity: usize) -> Self { pub fn newtype_wrapper(name: CtorName, arity: usize) -> Self {
let alternatives = vec![Ctor { let alternatives = vec![Ctor {
name: tag_name, name,
tag_id: TagId(0), tag_id: TagId(0),
arity, arity,
}]; }];
@ -40,9 +43,24 @@ pub enum RenderAs {
#[derive(Clone, Debug, PartialEq, Eq, Hash, Copy)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Copy)]
pub struct TagId(pub TagIdIntType); pub struct TagId(pub TagIdIntType);
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum CtorName {
Tag(TagName),
Opaque(Symbol),
}
impl CtorName {
pub fn is_tag(&self, tag_name: &TagName) -> bool {
match self {
Self::Tag(test) => test == tag_name,
_ => false,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Ctor { pub struct Ctor {
pub name: TagName, pub name: CtorName,
pub tag_id: TagId, pub tag_id: TagId,
pub arity: usize, pub arity: usize,
} }

View file

@ -913,9 +913,6 @@ trait Backend<'a> {
TagName::Closure(sym) => { TagName::Closure(sym) => {
self.set_last_seen(*sym, stmt); self.set_last_seen(*sym, stmt);
} }
TagName::Private(sym) => {
self.set_last_seen(*sym, stmt);
}
TagName::Global(_) => {} TagName::Global(_) => {}
} }
for sym in *arguments { for sym in *arguments {

View file

@ -53,10 +53,6 @@ pub enum TagName {
/// into integers. (Record field labels work the same way, for the same reason.) /// into integers. (Record field labels work the same way, for the same reason.)
Global(Uppercase), Global(Uppercase),
/// Private tags are associated with a specific module, and as such use a
/// Symbol just like all other module-specific identifiers.
Private(Symbol),
/// Used to connect the closure size to the function it corresponds to /// Used to connect the closure size to the function it corresponds to
Closure(Symbol), Closure(Symbol),
} }
@ -69,9 +65,6 @@ impl TagName {
pub fn as_ident_str(&self, interns: &Interns, home: ModuleId) -> IdentStr { pub fn as_ident_str(&self, interns: &Interns, home: ModuleId) -> IdentStr {
match self { match self {
TagName::Global(uppercase) => uppercase.as_ident_str().clone(), TagName::Global(uppercase) => uppercase.as_ident_str().clone(),
TagName::Private(symbol) => {
symbol.fully_qualified(interns, home).as_ident_str().clone()
}
TagName::Closure(symbol) => { TagName::Closure(symbol) => {
symbol.fully_qualified(interns, home).as_ident_str().clone() symbol.fully_qualified(interns, home).as_ident_str().clone()
} }

View file

@ -4,7 +4,7 @@ use crate::ir::{
use crate::layout::{Builtin, Layout, LayoutCache, TagIdIntType, UnionLayout}; use crate::layout::{Builtin, Layout, LayoutCache, TagIdIntType, UnionLayout};
use roc_builtins::bitcode::{FloatWidth, IntWidth}; use roc_builtins::bitcode::{FloatWidth, IntWidth};
use roc_collections::all::{MutMap, MutSet}; use roc_collections::all::{MutMap, MutSet};
use roc_exhaustive::{Ctor, RenderAs, TagId, Union}; use roc_exhaustive::{Ctor, CtorName, RenderAs, TagId, Union};
use roc_module::ident::TagName; use roc_module::ident::TagName;
use roc_module::low_level::LowLevel; use roc_module::low_level::LowLevel;
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
@ -82,7 +82,7 @@ enum GuardedTest<'a> {
enum Test<'a> { enum Test<'a> {
IsCtor { IsCtor {
tag_id: TagIdIntType, tag_id: TagIdIntType,
tag_name: TagName, ctor_name: CtorName,
union: roc_exhaustive::Union, union: roc_exhaustive::Union,
arguments: Vec<(Pattern<'a>, Layout<'a>)>, arguments: Vec<(Pattern<'a>, Layout<'a>)>,
}, },
@ -512,7 +512,7 @@ fn test_at_path<'a>(
render_as: RenderAs::Tag, render_as: RenderAs::Tag,
alternatives: vec![Ctor { alternatives: vec![Ctor {
tag_id: TagId(0), tag_id: TagId(0),
name: TagName::Global(RECORD_TAG_NAME.into()), name: CtorName::Tag(TagName::Global(RECORD_TAG_NAME.into())),
arity: destructs.len(), arity: destructs.len(),
}], }],
}; };
@ -532,7 +532,7 @@ fn test_at_path<'a>(
IsCtor { IsCtor {
tag_id: 0, tag_id: 0,
tag_name: TagName::Global(RECORD_TAG_NAME.into()), ctor_name: CtorName::Tag(TagName::Global(RECORD_TAG_NAME.into())),
union, union,
arguments, arguments,
} }
@ -543,11 +543,12 @@ fn test_at_path<'a>(
arguments, arguments,
} => { } => {
let tag_id = 0; let tag_id = 0;
let union = Union::newtype_wrapper(tag_name.clone(), arguments.len()); let union =
Union::newtype_wrapper(CtorName::Tag(tag_name.clone()), arguments.len());
IsCtor { IsCtor {
tag_id, tag_id,
tag_name: tag_name.clone(), ctor_name: CtorName::Tag(tag_name.clone()),
union, union,
arguments: arguments.to_vec(), arguments: arguments.to_vec(),
} }
@ -561,7 +562,7 @@ fn test_at_path<'a>(
.. ..
} => IsCtor { } => IsCtor {
tag_id: *tag_id, tag_id: *tag_id,
tag_name: tag_name.clone(), ctor_name: CtorName::Tag(tag_name.clone()),
union: union.clone(), union: union.clone(),
arguments: arguments.to_vec(), arguments: arguments.to_vec(),
}, },
@ -571,14 +572,14 @@ fn test_at_path<'a>(
render_as: RenderAs::Tag, render_as: RenderAs::Tag,
alternatives: vec![Ctor { alternatives: vec![Ctor {
tag_id: TagId(0), tag_id: TagId(0),
name: TagName::Private(*opaque), name: CtorName::Opaque(*opaque),
arity: 1, arity: 1,
}], }],
}; };
IsCtor { IsCtor {
tag_id: 0, tag_id: 0,
tag_name: TagName::Private(*opaque), ctor_name: CtorName::Opaque(*opaque),
union, union,
arguments: vec![(**argument).clone()], arguments: vec![(**argument).clone()],
} }
@ -680,11 +681,11 @@ fn to_relevant_branch_help<'a>(
RecordDestructure(destructs, _) => match test { RecordDestructure(destructs, _) => match test {
IsCtor { IsCtor {
tag_name: test_name, ctor_name: test_name,
tag_id, tag_id,
.. ..
} => { } => {
debug_assert!(test_name == &TagName::Global(RECORD_TAG_NAME.into())); debug_assert!(test_name == &CtorName::Tag(TagName::Global(RECORD_TAG_NAME.into())));
let sub_positions = destructs.into_iter().enumerate().map(|(index, destruct)| { let sub_positions = destructs.into_iter().enumerate().map(|(index, destruct)| {
let pattern = match destruct.typ { let pattern = match destruct.typ {
DestructType::Guard(guard) => guard.clone(), DestructType::Guard(guard) => guard.clone(),
@ -713,11 +714,11 @@ fn to_relevant_branch_help<'a>(
OpaqueUnwrap { opaque, argument } => match test { OpaqueUnwrap { opaque, argument } => match test {
IsCtor { IsCtor {
tag_name: test_opaque_tag_name, ctor_name: test_opaque_tag_name,
tag_id, tag_id,
.. ..
} => { } => {
debug_assert_eq!(test_opaque_tag_name, &TagName::Private(opaque)); debug_assert_eq!(test_opaque_tag_name, &CtorName::Opaque(opaque));
let (argument, _) = *argument; let (argument, _) = *argument;
@ -744,10 +745,10 @@ fn to_relevant_branch_help<'a>(
.. ..
} => match test { } => match test {
IsCtor { IsCtor {
tag_name: test_name, ctor_name: test_name,
tag_id: test_id, tag_id: test_id,
.. ..
} if &tag_name == test_name => { } if test_name.is_tag(&tag_name) => {
let tag_id = 0; let tag_id = 0;
debug_assert_eq!(tag_id, *test_id); debug_assert_eq!(tag_id, *test_id);
@ -785,10 +786,10 @@ fn to_relevant_branch_help<'a>(
} => { } => {
match test { match test {
IsCtor { IsCtor {
tag_name: test_name, ctor_name: test_name,
tag_id: test_id, tag_id: test_id,
.. ..
} if &tag_name == test_name => { } if test_name.is_tag(&tag_name) => {
debug_assert_eq!(tag_id, *test_id); debug_assert_eq!(tag_id, *test_id);
// the test matches the constructor of this pattern // the test matches the constructor of this pattern

View file

@ -1,7 +1,7 @@
use crate::ir::DestructType; use crate::ir::DestructType;
use roc_collections::all::HumanIndex; use roc_collections::all::HumanIndex;
use roc_exhaustive::{ use roc_exhaustive::{
is_useful, Context, Ctor, Error, Guard, Literal, Pattern, RenderAs, TagId, Union, is_useful, Context, Ctor, CtorName, Error, Guard, Literal, Pattern, RenderAs, TagId, Union,
}; };
use roc_module::ident::{TagIdIntType, TagName}; use roc_module::ident::{TagIdIntType, TagName};
use roc_region::all::{Loc, Region}; use roc_region::all::{Loc, Region};
@ -45,7 +45,7 @@ fn simplify(pattern: &crate::ir::Pattern) -> Pattern {
let union = Union { let union = Union {
render_as: RenderAs::Record(field_names), render_as: RenderAs::Record(field_names),
alternatives: vec![Ctor { alternatives: vec![Ctor {
name: TagName::Global("#Record".into()), name: CtorName::Tag(TagName::Global("#Record".into())),
tag_id, tag_id,
arity: destructures.len(), arity: destructures.len(),
}], }],
@ -62,7 +62,7 @@ fn simplify(pattern: &crate::ir::Pattern) -> Pattern {
let simplified_args: std::vec::Vec<_> = let simplified_args: std::vec::Vec<_> =
arguments.iter().map(|v| simplify(&v.0)).collect(); arguments.iter().map(|v| simplify(&v.0)).collect();
Ctor( Ctor(
Union::newtype_wrapper(tag_name.clone(), arguments.len()), Union::newtype_wrapper(CtorName::Tag(tag_name.clone()), arguments.len()),
TagId(tag_id), TagId(tag_id),
simplified_args, simplified_args,
) )
@ -87,7 +87,7 @@ fn simplify(pattern: &crate::ir::Pattern) -> Pattern {
let union = Union { let union = Union {
render_as: RenderAs::Opaque, render_as: RenderAs::Opaque,
alternatives: vec![Ctor { alternatives: vec![Ctor {
name: TagName::Private(*opaque), name: CtorName::Opaque(*opaque),
tag_id, tag_id,
arity: 1, arity: 1,
}], }],
@ -169,7 +169,7 @@ fn to_nonredundant_rows(
render_as: RenderAs::Guard, render_as: RenderAs::Guard,
alternatives: vec![Ctor { alternatives: vec![Ctor {
tag_id, tag_id,
name: TagName::Global("#Guard".into()), name: CtorName::Tag(TagName::Global("#Guard".into())),
arity: 2, arity: 2,
}], }],
}; };

View file

@ -10,7 +10,7 @@ use roc_builtins::bitcode::{FloatWidth, IntWidth};
use roc_can::abilities::AbilitiesStore; use roc_can::abilities::AbilitiesStore;
use roc_can::expr::{ClosureData, IntValue}; use roc_can::expr::{ClosureData, IntValue};
use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, MutMap}; use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, MutMap};
use roc_exhaustive::{Ctor, Guard, RenderAs, TagId}; use roc_exhaustive::{Ctor, CtorName, Guard, RenderAs, TagId};
use roc_module::ident::{ForeignSymbol, Lowercase, TagName}; use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
use roc_module::low_level::LowLevel; use roc_module::low_level::LowLevel;
use roc_module::symbol::{IdentIds, ModuleId, Symbol}; use roc_module::symbol::{IdentIds, ModuleId, Symbol};
@ -1656,7 +1656,6 @@ impl<'a> Expr<'a> {
} => { } => {
let doc_tag = match tag_name { let doc_tag = match tag_name {
TagName::Global(s) => alloc.text(s.as_str()), TagName::Global(s) => alloc.text(s.as_str()),
TagName::Private(s) => symbol_to_doc(alloc, *s),
TagName::Closure(s) => alloc TagName::Closure(s) => alloc
.text("ClosureTag(") .text("ClosureTag(")
.append(symbol_to_doc(alloc, *s)) .append(symbol_to_doc(alloc, *s))
@ -1678,7 +1677,6 @@ impl<'a> Expr<'a> {
} => { } => {
let doc_tag = match tag_name { let doc_tag = match tag_name {
TagName::Global(s) => alloc.text(s.as_str()), TagName::Global(s) => alloc.text(s.as_str()),
TagName::Private(s) => alloc.text(format!("{}", s)),
TagName::Closure(s) => alloc TagName::Closure(s) => alloc
.text("ClosureTag(") .text("ClosureTag(")
.append(symbol_to_doc(alloc, *s)) .append(symbol_to_doc(alloc, *s))
@ -8039,7 +8037,7 @@ fn from_can_pattern_help<'a>(
render_as: RenderAs::Tag, render_as: RenderAs::Tag,
alternatives: vec![Ctor { alternatives: vec![Ctor {
tag_id: TagId(0), tag_id: TagId(0),
name: tag_name.clone(), name: CtorName::Tag(tag_name.clone()),
arity: 0, arity: 0,
}], }],
}, },
@ -8052,12 +8050,12 @@ fn from_can_pattern_help<'a>(
alternatives: vec![ alternatives: vec![
Ctor { Ctor {
tag_id: TagId(0), tag_id: TagId(0),
name: ffalse, name: CtorName::Tag(ffalse),
arity: 0, arity: 0,
}, },
Ctor { Ctor {
tag_id: TagId(1), tag_id: TagId(1),
name: ttrue, name: CtorName::Tag(ttrue),
arity: 0, arity: 0,
}, },
], ],
@ -8073,7 +8071,7 @@ fn from_can_pattern_help<'a>(
for (i, tag_name) in tag_names.into_iter().enumerate() { for (i, tag_name) in tag_names.into_iter().enumerate() {
ctors.push(Ctor { ctors.push(Ctor {
tag_id: TagId(i as _), tag_id: TagId(i as _),
name: tag_name, name: CtorName::Tag(tag_name),
arity: 0, arity: 0,
}) })
} }
@ -8164,7 +8162,7 @@ fn from_can_pattern_help<'a>(
for (i, (tag_name, args)) in tags.iter().enumerate() { for (i, (tag_name, args)) in tags.iter().enumerate() {
ctors.push(Ctor { ctors.push(Ctor {
tag_id: TagId(i as _), tag_id: TagId(i as _),
name: tag_name.clone(), name: CtorName::Tag(tag_name.clone()),
arity: args.len(), arity: args.len(),
}) })
} }
@ -8215,7 +8213,7 @@ fn from_can_pattern_help<'a>(
for (i, (tag_name, args)) in tags.iter().enumerate() { for (i, (tag_name, args)) in tags.iter().enumerate() {
ctors.push(Ctor { ctors.push(Ctor {
tag_id: TagId(i as _), tag_id: TagId(i as _),
name: tag_name.clone(), name: CtorName::Tag(tag_name.clone()),
// don't include tag discriminant in arity // don't include tag discriminant in arity
arity: args.len() - 1, arity: args.len() - 1,
}) })
@ -8260,7 +8258,7 @@ fn from_can_pattern_help<'a>(
ctors.push(Ctor { ctors.push(Ctor {
tag_id: TagId(0), tag_id: TagId(0),
name: tag_name.clone(), name: CtorName::Tag(tag_name.clone()),
arity: fields.len(), arity: fields.len(),
}); });
@ -8307,7 +8305,7 @@ fn from_can_pattern_help<'a>(
if i == nullable_id as usize { if i == nullable_id as usize {
ctors.push(Ctor { ctors.push(Ctor {
tag_id: TagId(i as _), tag_id: TagId(i as _),
name: nullable_name.clone(), name: CtorName::Tag(nullable_name.clone()),
// don't include tag discriminant in arity // don't include tag discriminant in arity
arity: 0, arity: 0,
}); });
@ -8317,7 +8315,7 @@ fn from_can_pattern_help<'a>(
ctors.push(Ctor { ctors.push(Ctor {
tag_id: TagId(i as _), tag_id: TagId(i as _),
name: tag_name.clone(), name: CtorName::Tag(tag_name.clone()),
// don't include tag discriminant in arity // don't include tag discriminant in arity
arity: args.len() - 1, arity: args.len() - 1,
}); });
@ -8328,7 +8326,7 @@ fn from_can_pattern_help<'a>(
if i == nullable_id as usize { if i == nullable_id as usize {
ctors.push(Ctor { ctors.push(Ctor {
tag_id: TagId(i as _), tag_id: TagId(i as _),
name: nullable_name.clone(), name: CtorName::Tag(nullable_name.clone()),
// don't include tag discriminant in arity // don't include tag discriminant in arity
arity: 0, arity: 0,
}); });
@ -8378,13 +8376,13 @@ fn from_can_pattern_help<'a>(
ctors.push(Ctor { ctors.push(Ctor {
tag_id: TagId(nullable_id as _), tag_id: TagId(nullable_id as _),
name: nullable_name.clone(), name: CtorName::Tag(nullable_name.clone()),
arity: 0, arity: 0,
}); });
ctors.push(Ctor { ctors.push(Ctor {
tag_id: TagId(!nullable_id as _), tag_id: TagId(!nullable_id as _),
name: nullable_name.clone(), name: CtorName::Tag(nullable_name.clone()),
// FIXME drop tag // FIXME drop tag
arity: other_fields.len() - 1, arity: other_fields.len() - 1,
}); });

View file

@ -344,7 +344,6 @@ impl LambdaSet {
layouts.symbols.push(*symbol); layouts.symbols.push(*symbol);
} }
TagName::Global(_) => unreachable!("lambda set tags must be closure tags"), TagName::Global(_) => unreachable!("lambda set tags must be closure tags"),
TagName::Private(_) => unreachable!("lambda set tags must be closure tags"),
} }
} }

View file

@ -1076,10 +1076,3 @@ pub fn set_type(a: SolvedType) -> SolvedType {
pub fn dict_type(key: SolvedType, value: SolvedType) -> SolvedType { pub fn dict_type(key: SolvedType, value: SolvedType) -> SolvedType {
SolvedType::Apply(Symbol::DICT_DICT, vec![key, value]) SolvedType::Apply(Symbol::DICT_DICT, vec![key, value])
} }
pub fn single_private_tag(symbol: Symbol, type_arguments: Vec<SolvedType>) -> SolvedType {
SolvedType::TagUnion(
vec![(TagName::Private(symbol), type_arguments)],
Box::new(SolvedType::EmptyTagUnion),
)
}

View file

@ -114,7 +114,6 @@ fn round_to_multiple_of(value: usize, base: usize) -> usize {
enum SerializedTagName { enum SerializedTagName {
Global(SubsSlice<u8>), Global(SubsSlice<u8>),
Private(Symbol),
Closure(Symbol), Closure(Symbol),
} }
@ -211,7 +210,6 @@ impl Subs {
); );
SerializedTagName::Global(slice) SerializedTagName::Global(slice)
} }
TagName::Private(symbol) => SerializedTagName::Private(*symbol),
TagName::Closure(symbol) => SerializedTagName::Closure(*symbol), TagName::Closure(symbol) => SerializedTagName::Closure(*symbol),
}; };
@ -354,7 +352,6 @@ impl Subs {
TagName::Global(string.into()) TagName::Global(string.into())
} }
SerializedTagName::Private(symbol) => TagName::Private(*symbol),
SerializedTagName::Closure(symbol) => TagName::Closure(*symbol), SerializedTagName::Closure(symbol) => TagName::Closure(*symbol),
}; };
@ -410,12 +407,10 @@ impl TagNameCache {
None => None, None => None,
} }
} }
TagName::Private(symbol) | TagName::Closure(symbol) => { TagName::Closure(symbol) => match self.symbols.iter().position(|s| s == symbol) {
match self.symbols.iter().position(|s| s == symbol) { Some(index) => Some(&mut self.symbols_slices[index]),
Some(index) => Some(&mut self.symbols_slices[index]), None => None,
None => None, },
}
}
} }
} }
@ -425,7 +420,7 @@ impl TagNameCache {
self.globals.push(uppercase.clone()); self.globals.push(uppercase.clone());
self.globals_slices.push(slice); self.globals_slices.push(slice);
} }
TagName::Private(symbol) | TagName::Closure(symbol) => { TagName::Closure(symbol) => {
self.symbols.push(*symbol); self.symbols.push(*symbol);
self.symbols_slices.push(slice); self.symbols_slices.push(slice);
} }

View file

@ -475,7 +475,7 @@ fn tag_name_to_expr<'a>(env: &Env<'a, '_>, tag_name: &TagName) -> Expr<'a> {
env.arena env.arena
.alloc_str(&tag_name.as_ident_str(env.interns, env.home)), .alloc_str(&tag_name.as_ident_str(env.interns, env.home)),
), ),
TagName::Private(_) | TagName::Closure(_) => unreachable!("User cannot type this"), TagName::Closure(_) => unreachable!("User cannot type this"),
} }
} }

View file

@ -145,7 +145,7 @@ fn pattern_to_doc_help<'b>(
) -> RocDocBuilder<'b> { ) -> RocDocBuilder<'b> {
use roc_exhaustive::Literal::*; use roc_exhaustive::Literal::*;
use roc_exhaustive::Pattern::*; use roc_exhaustive::Pattern::*;
use roc_exhaustive::RenderAs; use roc_exhaustive::{CtorName, RenderAs};
match pattern { match pattern {
Anything => alloc.text("_"), Anything => alloc.text("_"),
@ -163,10 +163,9 @@ fn pattern_to_doc_help<'b>(
match union.render_as { match union.render_as {
RenderAs::Guard => { RenderAs::Guard => {
// #Guard <fake-condition-tag> <unexhausted-pattern> // #Guard <fake-condition-tag> <unexhausted-pattern>
debug_assert_eq!( debug_assert!(union.alternatives[tag_id.0 as usize]
union.alternatives[tag_id.0 as usize].name, .name
TagName::Global("#Guard".into()) .is_tag(&TagName::Global("#Guard".into())),);
);
debug_assert!(args.len() == 2); debug_assert!(args.len() == 2);
let tag = pattern_to_doc_help(alloc, args[1].clone(), in_type_param); let tag = pattern_to_doc_help(alloc, args[1].clone(), in_type_param);
alloc.concat([ alloc.concat([
@ -207,18 +206,17 @@ fn pattern_to_doc_help<'b>(
.into_iter() .into_iter()
.map(|v| pattern_to_doc_help(alloc, v, true)); .map(|v| pattern_to_doc_help(alloc, v, true));
let tag = &union.alternatives[tag_id.0 as usize]; let ctor = &union.alternatives[tag_id.0 as usize];
let tag_name = match union.render_as { let tag_name = match (union.render_as, &ctor.name) {
RenderAs::Tag => alloc.tag_name(tag.name.clone()), (RenderAs::Tag, CtorName::Tag(tag)) => alloc.tag_name(tag.clone()),
RenderAs::Opaque => match tag.name { (RenderAs::Opaque, CtorName::Opaque(opaque)) => {
TagName::Private(opaque) => alloc.wrapped_opaque_name(opaque), alloc.wrapped_opaque_name(*opaque)
_ => unreachable!(), }
},
_ => unreachable!(), _ => unreachable!(),
}; };
// We assume the alternatives are sorted. If not, this assert will trigger // We assume the alternatives are sorted. If not, this assert will trigger
debug_assert!(tag_id == tag.tag_id); debug_assert!(tag_id == ctor.tag_id);
let docs = std::iter::once(tag_name).chain(arg_docs); let docs = std::iter::once(tag_name).chain(arg_docs);

View file

@ -1449,17 +1449,6 @@ fn format_category<'b>(
]), ]),
alloc.text(" has the type:"), alloc.text(" has the type:"),
), ),
TagApply {
tag_name: TagName::Private(name),
args_count: 0,
} => (
alloc.concat([
alloc.text(format!("{}his ", t)),
alloc.private_tag_name(*name),
alloc.text(" private tag"),
]),
alloc.text(" has the type:"),
),
TagApply { TagApply {
tag_name: TagName::Global(name), tag_name: TagName::Global(name),
@ -1472,17 +1461,6 @@ fn format_category<'b>(
]), ]),
alloc.text(" has the type:"), alloc.text(" has the type:"),
), ),
TagApply {
tag_name: TagName::Private(name),
args_count: _,
} => (
alloc.concat([
alloc.text("This "),
alloc.private_tag_name(*name),
alloc.text(" private tag application"),
]),
alloc.text(" has the type:"),
),
TagApply { TagApply {
tag_name: TagName::Closure(_name), tag_name: TagName::Closure(_name),
args_count: _, args_count: _,

View file

@ -386,9 +386,7 @@ impl<'a> RocDocAllocator<'a> {
pub fn tag_name(&'a self, tn: TagName) -> DocBuilder<'a, Self, Annotation> { pub fn tag_name(&'a self, tn: TagName) -> DocBuilder<'a, Self, Annotation> {
match tn { match tn {
TagName::Global(uppercase) => self.global_tag_name(uppercase), TagName::Global(uppercase) => self.global_tag_name(uppercase),
TagName::Private(symbol) => self.private_tag_name(symbol), TagName::Closure(_symbol) => unreachable!("closure tags are internal only"),
TagName::Closure(symbol) => self.private_tag_name(symbol),
// TagName::Closure(_symbol) => unreachable!("closure tags are internal only"),
} }
} }