Unnamed repository; edit this file 'description' to name the repository.
Move ty lowering diagnostic definitions into a separate module
To keep them organized.
Chayim Refael Friedman 2024-12-20
parent 15d2d50 · commit 82896b2
-rw-r--r--crates/hir-ty/src/infer.rs2
-rw-r--r--crates/hir-ty/src/lib.rs6
-rw-r--r--crates/hir-ty/src/lower.rs28
-rw-r--r--crates/hir-ty/src/lower/diagnostics.rs27
4 files changed, 34 insertions, 29 deletions
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index dbee5a1a91..5720539d34 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -58,7 +58,7 @@ use crate::{
fold_tys,
generics::Generics,
infer::{coerce::CoerceMany, expr::ExprIsRead, unify::InferenceTable},
- lower::{ImplTraitLoweringMode, TyLoweringDiagnostic},
+ lower::{diagnostics::TyLoweringDiagnostic, ImplTraitLoweringMode},
mir::MirSpan,
to_assoc_type_id,
traits::FnTrait,
diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs
index 8bb90ca31e..224fcf313a 100644
--- a/crates/hir-ty/src/lib.rs
+++ b/crates/hir-ty/src/lib.rs
@@ -88,10 +88,10 @@ pub use infer::{
PointerCast,
};
pub use interner::Interner;
+pub use lower::diagnostics::*;
pub use lower::{
- associated_type_shorthand_candidates, GenericArgsProhibitedReason, ImplTraitLoweringMode,
- ParamLoweringMode, TyDefId, TyLoweringContext, TyLoweringDiagnostic, TyLoweringDiagnosticKind,
- ValueTyDefId,
+ associated_type_shorthand_candidates, ImplTraitLoweringMode, ParamLoweringMode, TyDefId,
+ TyLoweringContext, ValueTyDefId,
};
pub use mapping::{
from_assoc_type_id, from_chalk_trait_id, from_foreign_def_id, from_placeholder_idx,
diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs
index b23f2749ab..2610bb704e 100644
--- a/crates/hir-ty/src/lower.rs
+++ b/crates/hir-ty/src/lower.rs
@@ -5,6 +5,8 @@
//! - Building the type for an item: This happens through the `ty` query.
//!
//! This usually involves resolving names, collecting generic arguments etc.
+pub(crate) mod diagnostics;
+
use std::{
cell::OnceCell,
iter, mem,
@@ -59,6 +61,7 @@ use crate::{
db::HirDatabase,
error_lifetime,
generics::{generics, trait_self_param_idx, Generics},
+ lower::diagnostics::*,
make_binders,
mapping::{from_chalk_trait_id, lt_to_placeholder_idx, ToChalk},
static_lifetime, to_assoc_type_id, to_chalk_trait_id, to_placeholder_idx,
@@ -102,31 +105,6 @@ impl ImplTraitLoweringState {
}
}
-type TypeSource = Either<TypeRefId, hir_def::type_ref::TypeSource>;
-
-#[derive(Debug, PartialEq, Eq, Clone)]
-pub struct TyLoweringDiagnostic {
- pub source: TypeSource,
- pub kind: TyLoweringDiagnosticKind,
-}
-
-#[derive(Debug, PartialEq, Eq, Clone)]
-pub enum TyLoweringDiagnosticKind {
- GenericArgsProhibited { segment: u32, reason: GenericArgsProhibitedReason },
-}
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum GenericArgsProhibitedReason {
- Module,
- TyParam,
- SelfTy,
- PrimitiveTy,
- /// When there is a generic enum, within the expression `Enum::Variant`,
- /// either `Enum` or `Variant` are allowed to have generic arguments, but not both.
- // FIXME: This is not used now but it should be.
- EnumVariant,
-}
-
#[derive(Debug)]
pub struct TyLoweringContext<'a> {
pub db: &'a dyn HirDatabase,
diff --git a/crates/hir-ty/src/lower/diagnostics.rs b/crates/hir-ty/src/lower/diagnostics.rs
new file mode 100644
index 0000000000..61fedc8c3a
--- /dev/null
+++ b/crates/hir-ty/src/lower/diagnostics.rs
@@ -0,0 +1,27 @@
+use either::Either;
+use hir_def::type_ref::TypeRefId;
+
+type TypeSource = Either<TypeRefId, hir_def::type_ref::TypeSource>;
+
+#[derive(Debug, PartialEq, Eq, Clone)]
+pub struct TyLoweringDiagnostic {
+ pub source: TypeSource,
+ pub kind: TyLoweringDiagnosticKind,
+}
+
+#[derive(Debug, PartialEq, Eq, Clone)]
+pub enum TyLoweringDiagnosticKind {
+ GenericArgsProhibited { segment: u32, reason: GenericArgsProhibitedReason },
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum GenericArgsProhibitedReason {
+ Module,
+ TyParam,
+ SelfTy,
+ PrimitiveTy,
+ /// When there is a generic enum, within the expression `Enum::Variant`,
+ /// either `Enum` or `Variant` are allowed to have generic arguments, but not both.
+ // FIXME: This is not used now but it should be.
+ EnumVariant,
+}