@@ -592,7 +592,7 @@ impl<'a> TyLoweringContext<'a> {
592
592
// this point (`trait_ref.substitution`).
593
593
let substitution = self . substs_from_path_segment (
594
594
segment,
595
- Some ( associated_ty. into ( ) ) ,
595
+ associated_ty. into ( ) ,
596
596
false ,
597
597
None ,
598
598
) ;
@@ -1007,7 +1007,7 @@ impl<'a> TyLoweringContext<'a> {
1007
1007
// that method to optionally take parent `Substitution` as we already know them at
1008
1008
// this point (`t.substitution`).
1009
1009
let substs =
1010
- self . substs_from_path_segment ( segment, Some ( associated_ty. into ( ) ) , false , None ) ;
1010
+ self . substs_from_path_segment ( segment, associated_ty. into ( ) , false , None ) ;
1011
1011
1012
1012
let len_self =
1013
1013
crate :: generics:: generics ( self . db . upcast ( ) , associated_ty. into ( ) ) . len_self ( ) ;
@@ -1037,9 +1037,9 @@ impl<'a> TyLoweringContext<'a> {
1037
1037
infer_args : bool ,
1038
1038
) -> Ty {
1039
1039
let generic_def = match typeable {
1040
- TyDefId :: BuiltinType ( _ ) => None ,
1041
- TyDefId :: AdtId ( it) => Some ( it. into ( ) ) ,
1042
- TyDefId :: TypeAliasId ( it) => Some ( it. into ( ) ) ,
1040
+ TyDefId :: BuiltinType ( builtin ) => return TyBuilder :: builtin ( builtin ) ,
1041
+ TyDefId :: AdtId ( it) => it. into ( ) ,
1042
+ TyDefId :: TypeAliasId ( it) => it. into ( ) ,
1043
1043
} ;
1044
1044
let substs = self . substs_from_path_segment ( segment, generic_def, infer_args, None ) ;
1045
1045
self . db . ty ( typeable) . substitute ( Interner , & substs)
@@ -1058,11 +1058,11 @@ impl<'a> TyLoweringContext<'a> {
1058
1058
) -> Substitution {
1059
1059
let last = path. segments ( ) . last ( ) ;
1060
1060
let ( segment, generic_def) = match resolved {
1061
- ValueTyDefId :: FunctionId ( it) => ( last, Some ( it. into ( ) ) ) ,
1062
- ValueTyDefId :: StructId ( it) => ( last, Some ( it. into ( ) ) ) ,
1063
- ValueTyDefId :: UnionId ( it) => ( last, Some ( it. into ( ) ) ) ,
1064
- ValueTyDefId :: ConstId ( it) => ( last, Some ( it. into ( ) ) ) ,
1065
- ValueTyDefId :: StaticId ( _) => ( last , None ) ,
1061
+ ValueTyDefId :: FunctionId ( it) => ( last, it. into ( ) ) ,
1062
+ ValueTyDefId :: StructId ( it) => ( last, it. into ( ) ) ,
1063
+ ValueTyDefId :: UnionId ( it) => ( last, it. into ( ) ) ,
1064
+ ValueTyDefId :: ConstId ( it) => ( last, it. into ( ) ) ,
1065
+ ValueTyDefId :: StaticId ( _) => return Substitution :: empty ( Interner ) ,
1066
1066
ValueTyDefId :: EnumVariantId ( var) => {
1067
1067
// the generic args for an enum variant may be either specified
1068
1068
// on the segment referring to the enum, or on the segment
@@ -1075,23 +1075,17 @@ impl<'a> TyLoweringContext<'a> {
1075
1075
Some ( segment) if segment. args_and_bindings . is_some ( ) => Some ( segment) ,
1076
1076
_ => last,
1077
1077
} ;
1078
- ( segment, Some ( var. lookup ( self . db . upcast ( ) ) . parent . into ( ) ) )
1078
+ ( segment, var. lookup ( self . db . upcast ( ) ) . parent . into ( ) )
1079
1079
}
1080
1080
} ;
1081
- if let Some ( segment) = segment {
1082
- self . substs_from_path_segment ( segment, generic_def, infer_args, None )
1083
- } else if let Some ( generic_def) = generic_def {
1084
- // lang item
1085
- self . substs_from_args_and_bindings ( None , Some ( generic_def) , infer_args, None )
1086
- } else {
1087
- Substitution :: empty ( Interner )
1088
- }
1081
+ let args_and_bindings = segment. and_then ( |it| it. args_and_bindings ) ;
1082
+ self . substs_from_args_and_bindings ( args_and_bindings, generic_def, infer_args, None )
1089
1083
}
1090
1084
1091
1085
pub ( super ) fn substs_from_path_segment (
1092
1086
& mut self ,
1093
1087
segment : PathSegment < ' _ > ,
1094
- def : Option < GenericDefId > ,
1088
+ def : GenericDefId ,
1095
1089
infer_args : bool ,
1096
1090
explicit_self_ty : Option < Ty > ,
1097
1091
) -> Substitution {
@@ -1106,12 +1100,10 @@ impl<'a> TyLoweringContext<'a> {
1106
1100
fn substs_from_args_and_bindings (
1107
1101
& mut self ,
1108
1102
args_and_bindings : Option < & GenericArgs > ,
1109
- def : Option < GenericDefId > ,
1103
+ def : GenericDefId ,
1110
1104
infer_args : bool ,
1111
1105
explicit_self_ty : Option < Ty > ,
1112
1106
) -> Substitution {
1113
- let Some ( def) = def else { return Substitution :: empty ( Interner ) } ;
1114
-
1115
1107
// Order is
1116
1108
// - Optional Self parameter
1117
1109
// - Lifetime parameters
@@ -1317,7 +1309,7 @@ impl<'a> TyLoweringContext<'a> {
1317
1309
resolved : TraitId ,
1318
1310
explicit_self_ty : Ty ,
1319
1311
) -> Substitution {
1320
- self . substs_from_path_segment ( segment, Some ( resolved. into ( ) ) , false , Some ( explicit_self_ty) )
1312
+ self . substs_from_path_segment ( segment, resolved. into ( ) , false , Some ( explicit_self_ty) )
1321
1313
}
1322
1314
1323
1315
pub ( crate ) fn lower_where_predicate < ' b > (
@@ -1445,7 +1437,7 @@ impl<'a> TyLoweringContext<'a> {
1445
1437
let substitution = self . substs_from_path_segment (
1446
1438
// FIXME: This is hack. We shouldn't really build `PathSegment` directly.
1447
1439
PathSegment { name : & binding. name , args_and_bindings : binding. args . as_ref ( ) } ,
1448
- Some ( associated_ty. into ( ) ) ,
1440
+ associated_ty. into ( ) ,
1449
1441
false , // this is not relevant
1450
1442
Some ( super_trait_ref. self_type_parameter ( Interner ) ) ,
1451
1443
) ;
0 commit comments