@@ -1727,19 +1727,19 @@ fn fn_sig_for_struct_constructor(db: &dyn HirDatabase, def: StructId) -> PolyFnS
1727
1727
}
1728
1728
1729
1729
/// Build the type of a tuple struct constructor.
1730
- fn type_for_struct_constructor ( db : & dyn HirDatabase , def : StructId ) -> Binders < Ty > {
1730
+ fn type_for_struct_constructor ( db : & dyn HirDatabase , def : StructId ) -> Option < Binders < Ty > > {
1731
1731
let struct_data = db. struct_data ( def) ;
1732
1732
match struct_data. variant_data . kind ( ) {
1733
- StructKind :: Record => unreachable ! ( "callers check for valueness of variant" ) ,
1734
- StructKind :: Unit => return type_for_adt ( db, def. into ( ) ) ,
1733
+ StructKind :: Record => None ,
1734
+ StructKind :: Unit => Some ( type_for_adt ( db, def. into ( ) ) ) ,
1735
1735
StructKind :: Tuple => {
1736
1736
let generics = generics ( db. upcast ( ) , AdtId :: from ( def) . into ( ) ) ;
1737
1737
let substs = generics. bound_vars_subst ( db, DebruijnIndex :: INNERMOST ) ;
1738
- make_binders (
1738
+ Some ( make_binders (
1739
1739
db,
1740
1740
& generics,
1741
1741
TyKind :: FnDef ( CallableDefId :: StructId ( def) . to_chalk ( db) , substs) . intern ( Interner ) ,
1742
- )
1742
+ ) )
1743
1743
}
1744
1744
}
1745
1745
}
@@ -1757,20 +1757,23 @@ fn fn_sig_for_enum_variant_constructor(db: &dyn HirDatabase, def: EnumVariantId)
1757
1757
}
1758
1758
1759
1759
/// Build the type of a tuple enum variant constructor.
1760
- fn type_for_enum_variant_constructor ( db : & dyn HirDatabase , def : EnumVariantId ) -> Binders < Ty > {
1760
+ fn type_for_enum_variant_constructor (
1761
+ db : & dyn HirDatabase ,
1762
+ def : EnumVariantId ,
1763
+ ) -> Option < Binders < Ty > > {
1761
1764
let e = def. lookup ( db. upcast ( ) ) . parent ;
1762
1765
match db. enum_variant_data ( def) . variant_data . kind ( ) {
1763
- StructKind :: Record => unreachable ! ( "callers check for valueness of variant" ) ,
1764
- StructKind :: Unit => return type_for_adt ( db, e. into ( ) ) ,
1766
+ StructKind :: Record => None ,
1767
+ StructKind :: Unit => Some ( type_for_adt ( db, e. into ( ) ) ) ,
1765
1768
StructKind :: Tuple => {
1766
1769
let generics = generics ( db. upcast ( ) , e. into ( ) ) ;
1767
1770
let substs = generics. bound_vars_subst ( db, DebruijnIndex :: INNERMOST ) ;
1768
- make_binders (
1771
+ Some ( make_binders (
1769
1772
db,
1770
1773
& generics,
1771
1774
TyKind :: FnDef ( CallableDefId :: EnumVariantId ( def) . to_chalk ( db) , substs)
1772
1775
. intern ( Interner ) ,
1773
- )
1776
+ ) )
1774
1777
}
1775
1778
}
1776
1779
}
@@ -1889,14 +1892,14 @@ pub(crate) fn ty_recover(db: &dyn HirDatabase, _cycle: &Cycle, def: &TyDefId) ->
1889
1892
make_binders ( db, & generics, TyKind :: Error . intern ( Interner ) )
1890
1893
}
1891
1894
1892
- pub ( crate ) fn value_ty_query ( db : & dyn HirDatabase , def : ValueTyDefId ) -> Binders < Ty > {
1895
+ pub ( crate ) fn value_ty_query ( db : & dyn HirDatabase , def : ValueTyDefId ) -> Option < Binders < Ty > > {
1893
1896
match def {
1894
- ValueTyDefId :: FunctionId ( it) => type_for_fn ( db, it) ,
1897
+ ValueTyDefId :: FunctionId ( it) => Some ( type_for_fn ( db, it) ) ,
1895
1898
ValueTyDefId :: StructId ( it) => type_for_struct_constructor ( db, it) ,
1896
- ValueTyDefId :: UnionId ( it) => type_for_adt ( db, it. into ( ) ) ,
1899
+ ValueTyDefId :: UnionId ( it) => Some ( type_for_adt ( db, it. into ( ) ) ) ,
1897
1900
ValueTyDefId :: EnumVariantId ( it) => type_for_enum_variant_constructor ( db, it) ,
1898
- ValueTyDefId :: ConstId ( it) => type_for_const ( db, it) ,
1899
- ValueTyDefId :: StaticId ( it) => type_for_static ( db, it) ,
1901
+ ValueTyDefId :: ConstId ( it) => Some ( type_for_const ( db, it) ) ,
1902
+ ValueTyDefId :: StaticId ( it) => Some ( type_for_static ( db, it) ) ,
1900
1903
}
1901
1904
}
1902
1905
0 commit comments