hir_ty/lower/
diagnostics.rs

1//! This files contains the declaration of diagnostics kinds for ty and path lowering.
2
3use either::Either;
4use hir_def::type_ref::TypeRefId;
5
6type TypeSource = Either<TypeRefId, hir_def::type_ref::TypeSource>;
7
8#[derive(Debug, PartialEq, Eq, Clone)]
9pub struct TyLoweringDiagnostic {
10    pub source: TypeSource,
11    pub kind: TyLoweringDiagnosticKind,
12}
13
14#[derive(Debug, PartialEq, Eq, Clone)]
15pub enum TyLoweringDiagnosticKind {
16    PathDiagnostic(PathLoweringDiagnostic),
17}
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub enum GenericArgsProhibitedReason {
21    Module,
22    TyParam,
23    SelfTy,
24    PrimitiveTy,
25    Const,
26    Static,
27    /// When there is a generic enum, within the expression `Enum::Variant`,
28    /// either `Enum` or `Variant` are allowed to have generic arguments, but not both.
29    EnumVariant,
30}
31
32#[derive(Debug, PartialEq, Eq, Clone)]
33pub enum PathLoweringDiagnostic {
34    GenericArgsProhibited { segment: u32, reason: GenericArgsProhibitedReason },
35    ParenthesizedGenericArgsWithoutFnTrait { segment: u32 },
36}