Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Wuerker committed Dec 20, 2023
1 parent a05847d commit 53a0e86
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion crates/hir-analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub struct Jar(
ty::diagnostics::ImplTraitDefDiagAccumulator,
ty::diagnostics::ImplDefDiagAccumulator,
ty::diagnostics::FuncDefDiagAccumulator,
ty::diagnostics::RecursiveAdtConstituentAccumulator,
ty::diagnostics::AdtRecursionConstituentAccumulator,
);

pub trait HirAnalysisDb: salsa::DbWithJar<Jar> + HirDb {
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-analysis/src/ty/def_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use super::{
},
visitor::{walk_ty, TyVisitor},
};
use crate::ty::diagnostics::RecursiveAdtConstituentAccumulator;
use crate::ty::diagnostics::AdtRecursionConstituentAccumulator;

/// This function implements analysis for the ADT definition.
/// The analysis includes the following:
Expand All @@ -69,7 +69,7 @@ pub fn analyze_adt(db: &dyn HirAnalysisDb, adt_ref: AdtRefId) {
}

if let Some(constituent) = check_recursive_adt(db, adt_ref) {
RecursiveAdtConstituentAccumulator::push(db, constituent);
AdtRecursionConstituentAccumulator::push(db, constituent);
}
}

Expand Down
20 changes: 10 additions & 10 deletions crates/hir-analysis/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct FuncDefDiagAccumulator(pub(super) TyDiagCollection);
#[salsa::accumulator]
pub struct TypeAliasDefDiagAccumulator(pub(super) TyDiagCollection);
#[salsa::accumulator]
pub struct RecursiveAdtConstituentAccumulator(pub(super) AdtRecursionConstituent);
pub struct AdtRecursionConstituentAccumulator(pub(super) AdtRecursionConstituent);

#[derive(Debug, PartialEq, Eq, Hash, Clone, derive_more::From)]
pub enum TyDiagCollection {
Expand All @@ -58,7 +58,7 @@ impl TyDiagCollection {
pub enum TyLowerDiag {
NotFullyAppliedType(DynLazySpan),
InvalidTypeArgKind(DynLazySpan, String),
RecursiveType(Vec<AdtRecursionConstituent>),
AdtRecursion(Vec<AdtRecursionConstituent>),

UnboundTypeAliasParam {
span: DynLazySpan,
Expand Down Expand Up @@ -117,8 +117,8 @@ impl TyLowerDiag {
Self::InvalidTypeArgKind(span, msg)
}

pub(super) fn recursive_type(constituents: Vec<AdtRecursionConstituent>) -> Self {
Self::RecursiveType(constituents)
pub(super) fn adt_recursion(constituents: Vec<AdtRecursionConstituent>) -> Self {
Self::AdtRecursion(constituents)
}

pub(super) fn unbound_type_alias_param(
Expand Down Expand Up @@ -181,7 +181,7 @@ impl TyLowerDiag {
match self {
Self::NotFullyAppliedType(_) => 0,
Self::InvalidTypeArgKind(_, _) => 1,
Self::RecursiveType { .. } => 2,
Self::AdtRecursion { .. } => 2,
Self::UnboundTypeAliasParam { .. } => 3,
Self::TypeAliasCycle { .. } => 4,
Self::InconsistentKindBound(_, _) => 5,
Expand All @@ -196,7 +196,7 @@ impl TyLowerDiag {
match self {
Self::NotFullyAppliedType(_) => "expected fully applied type".to_string(),
Self::InvalidTypeArgKind(_, _) => "invalid type argument kind".to_string(),
Self::RecursiveType { .. } => "recursive type is not allowed".to_string(),
Self::AdtRecursion { .. } => "recursive type is not allowed".to_string(),

Self::UnboundTypeAliasParam { .. } => {
"all type parameters of type alias must be given".to_string()
Expand Down Expand Up @@ -232,7 +232,7 @@ impl TyLowerDiag {
span.resolve(db),
)],

Self::RecursiveType(constituents) => {
Self::AdtRecursion(constituents) => {
let mut diags = vec![];

for AdtRecursionConstituent { from, to } in constituents {
Expand Down Expand Up @@ -1109,7 +1109,7 @@ pub fn adt_recursion_diags(constituents: &[AdtRecursionConstituent]) -> Vec<TyDi
// Constituents in this set cannot be used to construct other recursions.
let mut unified_constituents = indexset! {};

// `cur` is initially set to the first item in `constituents` that has not been included in another recursion.
// `cur` is set to the first item in `constituents` that has not been included in another recursion.
while let Some(mut cur) =
(0..constituents.len()).find(|index| !unified_constituents.contains(index))
{
Expand All @@ -1132,7 +1132,7 @@ pub fn adt_recursion_diags(constituents: &[AdtRecursionConstituent]) -> Vec<TyDi
}

diags.push(
TyLowerDiag::recursive_type(
TyLowerDiag::adt_recursion(
recursion
.iter()
.map(|index| constituents[*index].to_owned())
Expand All @@ -1147,7 +1147,7 @@ pub fn adt_recursion_diags(constituents: &[AdtRecursionConstituent]) -> Vec<TyDi

/// Constituent of an ADT recursion.
///
/// A full ADT recursion can be represented using a list of `AdtRecursionConstituents`.
/// A full ADT recursion can be represented using a list of `AdtRecursionConstituent`s.
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct AdtRecursionConstituent {
/// The ADT definition from which the constituent originates and its name span.
Expand Down
8 changes: 4 additions & 4 deletions crates/hir-analysis/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use self::{
analyze_type_alias,
},
diagnostics::{
adt_recursion_diags, AdtDefDiagAccumulator, FuncDefDiagAccumulator, ImplDefDiagAccumulator,
ImplTraitDefDiagAccumulator, RecursiveAdtConstituentAccumulator, TraitDefDiagAccumulator,
TypeAliasDefDiagAccumulator,
adt_recursion_diags, AdtDefDiagAccumulator, AdtRecursionConstituentAccumulator,
FuncDefDiagAccumulator, ImplDefDiagAccumulator, ImplTraitDefDiagAccumulator,
TraitDefDiagAccumulator, TypeAliasDefDiagAccumulator,
},
ty_def::AdtRefId,
};
Expand Down Expand Up @@ -66,7 +66,7 @@ impl<'db> ModuleAnalysisPass for TypeDefAnalysisPass<'db> {
.map(|adt| {
(
analyze_adt::accumulated::<AdtDefDiagAccumulator>(self.db, adt),
analyze_adt::accumulated::<RecursiveAdtConstituentAccumulator>(self.db, adt),
analyze_adt::accumulated::<AdtRecursionConstituentAccumulator>(self.db, adt),
)
})
.unzip();
Expand Down
2 changes: 1 addition & 1 deletion crates/uitest/fixtures/ty/def/recursive_type.fe
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ pub struct S5<T> {

pub struct S6 {
s: S5<S6>
}
}

0 comments on commit 53a0e86

Please sign in to comment.