@@ -592,7 +592,7 @@ impl<'a> TyLoweringContext<'a> {
592592 // this point (`trait_ref.substitution`).
593593 let substitution = self . substs_from_path_segment (
594594 segment,
595- Some ( associated_ty. into ( ) ) ,
595+ associated_ty. into ( ) ,
596596 false ,
597597 None ,
598598 ) ;
@@ -1007,7 +1007,7 @@ impl<'a> TyLoweringContext<'a> {
10071007 // that method to optionally take parent `Substitution` as we already know them at
10081008 // this point (`t.substitution`).
10091009 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 ) ;
10111011
10121012 let len_self =
10131013 crate :: generics:: generics ( self . db . upcast ( ) , associated_ty. into ( ) ) . len_self ( ) ;
@@ -1037,9 +1037,9 @@ impl<'a> TyLoweringContext<'a> {
10371037 infer_args : bool ,
10381038 ) -> Ty {
10391039 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 ( ) ,
10431043 } ;
10441044 let substs = self . substs_from_path_segment ( segment, generic_def, infer_args, None ) ;
10451045 self . db . ty ( typeable) . substitute ( Interner , & substs)
@@ -1058,11 +1058,11 @@ impl<'a> TyLoweringContext<'a> {
10581058 ) -> Substitution {
10591059 let last = path. segments ( ) . last ( ) ;
10601060 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 ) ,
10661066 ValueTyDefId :: EnumVariantId ( var) => {
10671067 // the generic args for an enum variant may be either specified
10681068 // on the segment referring to the enum, or on the segment
@@ -1075,23 +1075,17 @@ impl<'a> TyLoweringContext<'a> {
10751075 Some ( segment) if segment. args_and_bindings . is_some ( ) => Some ( segment) ,
10761076 _ => last,
10771077 } ;
1078- ( segment, Some ( var. lookup ( self . db . upcast ( ) ) . parent . into ( ) ) )
1078+ ( segment, var. lookup ( self . db . upcast ( ) ) . parent . into ( ) )
10791079 }
10801080 } ;
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 )
10891083 }
10901084
10911085 pub ( super ) fn substs_from_path_segment (
10921086 & mut self ,
10931087 segment : PathSegment < ' _ > ,
1094- def : Option < GenericDefId > ,
1088+ def : GenericDefId ,
10951089 infer_args : bool ,
10961090 explicit_self_ty : Option < Ty > ,
10971091 ) -> Substitution {
@@ -1106,12 +1100,10 @@ impl<'a> TyLoweringContext<'a> {
11061100 fn substs_from_args_and_bindings (
11071101 & mut self ,
11081102 args_and_bindings : Option < & GenericArgs > ,
1109- def : Option < GenericDefId > ,
1103+ def : GenericDefId ,
11101104 infer_args : bool ,
11111105 explicit_self_ty : Option < Ty > ,
11121106 ) -> Substitution {
1113- let Some ( def) = def else { return Substitution :: empty ( Interner ) } ;
1114-
11151107 // Order is
11161108 // - Optional Self parameter
11171109 // - Lifetime parameters
@@ -1317,7 +1309,7 @@ impl<'a> TyLoweringContext<'a> {
13171309 resolved : TraitId ,
13181310 explicit_self_ty : Ty ,
13191311 ) -> 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) )
13211313 }
13221314
13231315 pub ( crate ) fn lower_where_predicate < ' b > (
@@ -1445,7 +1437,7 @@ impl<'a> TyLoweringContext<'a> {
14451437 let substitution = self . substs_from_path_segment (
14461438 // FIXME: This is hack. We shouldn't really build `PathSegment` directly.
14471439 PathSegment { name : & binding. name , args_and_bindings : binding. args . as_ref ( ) } ,
1448- Some ( associated_ty. into ( ) ) ,
1440+ associated_ty. into ( ) ,
14491441 false , // this is not relevant
14501442 Some ( super_trait_ref. self_type_parameter ( Interner ) ) ,
14511443 ) ;
0 commit comments