Merge pull request #3480 from rtfeldman/types-dead-code

Get rid of more dead code due to builtins
This commit is contained in:
Folkert de Vries 2022-07-11 18:44:51 +02:00 committed by GitHub
commit a209c44e42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 111 additions and 423 deletions

View file

@ -41,10 +41,9 @@ use roc_parse::module::module_defs;
use roc_parse::parser::{FileError, Parser, SyntaxError};
use roc_region::all::{LineInfo, Loc, Region};
use roc_reporting::report::RenderTarget;
use roc_solve::module::SolvedModule;
use roc_solve::module::{Solved, SolvedModule};
use roc_solve::solve;
use roc_target::TargetInfo;
use roc_types::solved_types::Solved;
use roc_types::subs::{ExposedTypesStorageSubs, Subs, VarStore, Variable};
use roc_types::types::{Alias, AliasKind};
use std::collections::hash_map::Entry::{Occupied, Vacant};
@ -4875,7 +4874,7 @@ fn build_pending_specializations<'a>(
Msg::FoundSpecializations {
module_id: home,
solved_subs: roc_types::solved_types::Solved(subs),
solved_subs: Solved(subs),
ident_ids,
layout_cache,
procs_base,

View file

@ -8,10 +8,28 @@ use roc_collections::VecMap;
use roc_derive_key::GlobalDerivedSymbols;
use roc_error_macros::internal_error;
use roc_module::symbol::Symbol;
use roc_types::solved_types::Solved;
use roc_types::subs::{Content, ExposedTypesStorageSubs, FlatType, StorageSubs, Subs, Variable};
use roc_types::types::Alias;
/// A marker that a given Subs has been solved.
/// The only way to obtain a Solved<Subs> is by running the solver on it.
#[derive(Clone, Debug)]
pub struct Solved<T>(pub T);
impl<T> Solved<T> {
pub fn inner(&self) -> &'_ T {
&self.0
}
pub fn inner_mut(&mut self) -> &'_ mut T {
&mut self.0
}
pub fn into_inner(self) -> T {
self.0
}
}
#[derive(Debug)]
pub struct SolvedModule {
pub problems: Vec<solve::TypeError>,

View file

@ -2,6 +2,7 @@ use crate::ability::{
resolve_ability_specialization, type_implementing_specialization, AbilityImplError,
DeferredObligations, PendingDerivesTable, RequestedDeriveKey, Resolved, Unfulfilled,
};
use crate::module::Solved;
use bumpalo::Bump;
use roc_can::abilities::{AbilitiesStore, MemberSpecialization};
use roc_can::constraint::Constraint::{self, *};
@ -18,7 +19,6 @@ use roc_module::ident::TagName;
use roc_module::symbol::{ModuleId, Symbol};
use roc_problem::can::CycleEntry;
use roc_region::all::{Loc, Region};
use roc_types::solved_types::Solved;
use roc_types::subs::{
self, AliasVariables, Content, Descriptor, FlatType, GetSubsSlice, LambdaSet, Mark,
OptVariable, Rank, RecordFields, Subs, SubsIndex, SubsSlice, UlsOfVar, UnionLabels,

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,8 @@
#![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)]
pub mod builtin_aliases;
pub mod num;
pub mod pretty_print;
pub mod solved_types;
pub mod subs;
pub mod types;
mod unification_table;

View file

@ -1,90 +0,0 @@
use crate::subs::{VarId, Variable};
use crate::types::{AliasKind, Problem, RecordField};
use roc_collections::all::ImMap;
use roc_module::ident::{Lowercase, TagName};
use roc_module::symbol::Symbol;
use roc_region::all::{Loc, Region};
/// A marker that a given Subs has been solved.
/// The only way to obtain a Solved<Subs> is by running the solver on it.
#[derive(Clone, Debug)]
pub struct Solved<T>(pub T);
impl<T> Solved<T> {
pub fn inner(&self) -> &'_ T {
&self.0
}
pub fn inner_mut(&mut self) -> &'_ mut T {
&mut self.0
}
pub fn into_inner(self) -> T {
self.0
}
}
#[derive(Debug, Clone)]
pub struct SolvedLambdaSet(pub SolvedType);
/// This is a fully solved type, with no Variables remaining in it.
#[derive(Debug, Clone)]
pub enum SolvedType {
/// A function. The types of its arguments, then the type of its return value.
Func(Vec<SolvedType>, Box<SolvedType>, Box<SolvedType>),
/// Applying a type to some arguments (e.g. Map.Map String Int)
Apply(Symbol, Vec<SolvedType>),
/// A bound type variable, e.g. `a` in `(a -> a)`
Rigid(Lowercase),
Flex(VarId),
Wildcard,
/// Inline type alias, e.g. `as List a` in `[Cons a (List a), Nil] as List a`
Record {
fields: Vec<(Lowercase, RecordField<SolvedType>)>,
/// The row type variable in an open record, e.g. the `r` in `{ name: Str }r`.
/// This is None if it's a closed record annotation like `{ name: Str }`.
ext: Box<SolvedType>,
},
EmptyRecord,
TagUnion(Vec<(TagName, Vec<SolvedType>)>, Box<SolvedType>),
LambdaTag(Symbol, Vec<SolvedType>),
FunctionOrTagUnion(TagName, Symbol, Box<SolvedType>),
RecursiveTagUnion(VarId, Vec<(TagName, Vec<SolvedType>)>, Box<SolvedType>),
EmptyTagUnion,
/// A type from an Invalid module
Erroneous(Problem),
Alias(
Symbol,
Vec<SolvedType>,
Vec<SolvedLambdaSet>,
Box<SolvedType>,
AliasKind,
),
HostExposedAlias {
name: Symbol,
arguments: Vec<SolvedType>,
lambda_set_variables: Vec<SolvedLambdaSet>,
actual_var: VarId,
actual: Box<SolvedType>,
},
/// A type error
Error,
}
#[derive(Clone, Debug)]
pub struct BuiltinAlias {
pub region: Region,
pub vars: Vec<Loc<Lowercase>>,
pub typ: SolvedType,
pub kind: AliasKind,
}
#[derive(Debug, Clone, Default)]
pub struct FreeVars {
pub named_vars: ImMap<Lowercase, Variable>,
pub unnamed_vars: ImMap<VarId, Variable>,
pub wildcards: Vec<Variable>,
}