Skip to content

Commit 82896b2

Browse files
Move ty lowering diagnostic definitions into a separate module
To keep them organized.
1 parent 15d2d50 commit 82896b2

File tree

4 files changed

+34
-29
lines changed

4 files changed

+34
-29
lines changed

crates/hir-ty/src/infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use crate::{
5858
fold_tys,
5959
generics::Generics,
6060
infer::{coerce::CoerceMany, expr::ExprIsRead, unify::InferenceTable},
61-
lower::{ImplTraitLoweringMode, TyLoweringDiagnostic},
61+
lower::{diagnostics::TyLoweringDiagnostic, ImplTraitLoweringMode},
6262
mir::MirSpan,
6363
to_assoc_type_id,
6464
traits::FnTrait,

crates/hir-ty/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ pub use infer::{
8888
PointerCast,
8989
};
9090
pub use interner::Interner;
91+
pub use lower::diagnostics::*;
9192
pub use lower::{
92-
associated_type_shorthand_candidates, GenericArgsProhibitedReason, ImplTraitLoweringMode,
93-
ParamLoweringMode, TyDefId, TyLoweringContext, TyLoweringDiagnostic, TyLoweringDiagnosticKind,
94-
ValueTyDefId,
93+
associated_type_shorthand_candidates, ImplTraitLoweringMode, ParamLoweringMode, TyDefId,
94+
TyLoweringContext, ValueTyDefId,
9595
};
9696
pub use mapping::{
9797
from_assoc_type_id, from_chalk_trait_id, from_foreign_def_id, from_placeholder_idx,

crates/hir-ty/src/lower.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
//! - Building the type for an item: This happens through the `ty` query.
66
//!
77
//! This usually involves resolving names, collecting generic arguments etc.
8+
pub(crate) mod diagnostics;
9+
810
use std::{
911
cell::OnceCell,
1012
iter, mem,
@@ -59,6 +61,7 @@ use crate::{
5961
db::HirDatabase,
6062
error_lifetime,
6163
generics::{generics, trait_self_param_idx, Generics},
64+
lower::diagnostics::*,
6265
make_binders,
6366
mapping::{from_chalk_trait_id, lt_to_placeholder_idx, ToChalk},
6467
static_lifetime, to_assoc_type_id, to_chalk_trait_id, to_placeholder_idx,
@@ -102,31 +105,6 @@ impl ImplTraitLoweringState {
102105
}
103106
}
104107

105-
type TypeSource = Either<TypeRefId, hir_def::type_ref::TypeSource>;
106-
107-
#[derive(Debug, PartialEq, Eq, Clone)]
108-
pub struct TyLoweringDiagnostic {
109-
pub source: TypeSource,
110-
pub kind: TyLoweringDiagnosticKind,
111-
}
112-
113-
#[derive(Debug, PartialEq, Eq, Clone)]
114-
pub enum TyLoweringDiagnosticKind {
115-
GenericArgsProhibited { segment: u32, reason: GenericArgsProhibitedReason },
116-
}
117-
118-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
119-
pub enum GenericArgsProhibitedReason {
120-
Module,
121-
TyParam,
122-
SelfTy,
123-
PrimitiveTy,
124-
/// When there is a generic enum, within the expression `Enum::Variant`,
125-
/// either `Enum` or `Variant` are allowed to have generic arguments, but not both.
126-
// FIXME: This is not used now but it should be.
127-
EnumVariant,
128-
}
129-
130108
#[derive(Debug)]
131109
pub struct TyLoweringContext<'a> {
132110
pub db: &'a dyn HirDatabase,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use either::Either;
2+
use hir_def::type_ref::TypeRefId;
3+
4+
type TypeSource = Either<TypeRefId, hir_def::type_ref::TypeSource>;
5+
6+
#[derive(Debug, PartialEq, Eq, Clone)]
7+
pub struct TyLoweringDiagnostic {
8+
pub source: TypeSource,
9+
pub kind: TyLoweringDiagnosticKind,
10+
}
11+
12+
#[derive(Debug, PartialEq, Eq, Clone)]
13+
pub enum TyLoweringDiagnosticKind {
14+
GenericArgsProhibited { segment: u32, reason: GenericArgsProhibitedReason },
15+
}
16+
17+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18+
pub enum GenericArgsProhibitedReason {
19+
Module,
20+
TyParam,
21+
SelfTy,
22+
PrimitiveTy,
23+
/// When there is a generic enum, within the expression `Enum::Variant`,
24+
/// either `Enum` or `Variant` are allowed to have generic arguments, but not both.
25+
// FIXME: This is not used now but it should be.
26+
EnumVariant,
27+
}

0 commit comments

Comments
 (0)