Remove other references to private tags in code

This commit is contained in:
Ayaz Hafiz 2022-04-25 11:50:00 -04:00
parent 2ab01107d3
commit 55706ae5c4
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
8 changed files with 32 additions and 99 deletions

View file

@ -1,7 +1,5 @@
use crate::docs::DocEntry::DetachedDoc;
use crate::docs::TypeAnnotation::{
Apply, BoundVariable, Function, NoTypeAnn, ObscuredRecord, ObscuredTagUnion, Record, TagUnion,
};
use crate::docs::TypeAnnotation::{Apply, BoundVariable, Function, NoTypeAnn, Record, TagUnion};
use crate::file::LoadedModule;
use roc_can::scope::Scope;
use roc_error_macros::todo_abilities;
@ -274,36 +272,20 @@ fn type_to_docs(in_func_type_ann: bool, type_annotation: ast::TypeAnnotation) ->
ast::TypeAnnotation::TagUnion { tags, ext } => {
let mut tags_to_render: Vec<Tag> = Vec::new();
let mut any_tags_are_private = false;
for tag in tags.iter() {
match tag_to_doc(in_func_type_ann, tag.value) {
None => {
any_tags_are_private = true;
break;
}
Some(tag_ann) => {
tags_to_render.push(tag_ann);
}
if let Some(tag_ann) = tag_to_doc(in_func_type_ann, tag.value) {
tags_to_render.push(tag_ann);
}
}
if any_tags_are_private {
if in_func_type_ann {
ObscuredTagUnion
} else {
NoTypeAnn
}
} else {
let extension = match ext {
None => NoTypeAnn,
Some(ext_type_ann) => type_to_docs(in_func_type_ann, ext_type_ann.value),
};
let extension = match ext {
None => NoTypeAnn,
Some(ext_type_ann) => type_to_docs(in_func_type_ann, ext_type_ann.value),
};
TagUnion {
tags: tags_to_render,
extension: Box::new(extension),
}
TagUnion {
tags: tags_to_render,
extension: Box::new(extension),
}
}
ast::TypeAnnotation::BoundVariable(var_name) => BoundVariable(var_name.to_string()),
@ -328,35 +310,19 @@ fn type_to_docs(in_func_type_ann: bool, type_annotation: ast::TypeAnnotation) ->
ast::TypeAnnotation::Record { fields, ext } => {
let mut doc_fields = Vec::new();
let mut any_fields_include_private_tags = false;
for field in fields.items {
match record_field_to_doc(in_func_type_ann, field.value) {
None => {
any_fields_include_private_tags = true;
break;
}
Some(doc_field) => {
doc_fields.push(doc_field);
}
if let Some(doc_field) = record_field_to_doc(in_func_type_ann, field.value) {
doc_fields.push(doc_field);
}
}
if any_fields_include_private_tags {
if in_func_type_ann {
ObscuredRecord
} else {
NoTypeAnn
}
} else {
let extension = match ext {
None => NoTypeAnn,
Some(ext_type_ann) => type_to_docs(in_func_type_ann, ext_type_ann.value),
};
let extension = match ext {
None => NoTypeAnn,
Some(ext_type_ann) => type_to_docs(in_func_type_ann, ext_type_ann.value),
};
Record {
fields: doc_fields,
extension: Box::new(extension),
}
Record {
fields: doc_fields,
extension: Box::new(extension),
}
}
ast::TypeAnnotation::SpaceBefore(&sub_type_ann, _) => {