@@ -4937,46 +4937,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4937
4937
_ => { }
4938
4938
}
4939
4939
4940
- let mut type_segment = None ;
4941
- let mut fn_segment = None ;
4942
- match def {
4943
- // Case 1. Reference to a struct/variant constructor.
4944
- Def :: StructCtor ( def_id, ..) |
4945
- Def :: VariantCtor ( def_id, ..) => {
4946
- // Everything but the final segment should have no
4947
- // parameters at all.
4948
- let mut generics = self . tcx . generics_of ( def_id) ;
4949
- if let Some ( def_id) = generics. parent {
4950
- // Variant and struct constructors use the
4951
- // generics of their parent type definition.
4952
- generics = self . tcx . generics_of ( def_id) ;
4953
- }
4954
- type_segment = Some ( ( segments. last ( ) . unwrap ( ) , generics) ) ;
4955
- }
4956
-
4957
- // Case 2. Reference to a top-level value.
4958
- Def :: Fn ( def_id) |
4959
- Def :: Const ( def_id) |
4960
- Def :: Static ( def_id, _) => {
4961
- fn_segment = Some ( ( segments. last ( ) . unwrap ( ) , self . tcx . generics_of ( def_id) ) ) ;
4962
- }
4963
-
4964
- // Case 3. Reference to a method or associated const.
4965
- Def :: Method ( def_id) |
4966
- Def :: AssociatedConst ( def_id) => {
4967
- let generics = self . tcx . generics_of ( def_id) ;
4968
- if segments. len ( ) >= 2 {
4969
- let parent_generics = self . tcx . generics_of ( generics. parent . unwrap ( ) ) ;
4970
- type_segment = Some ( ( & segments[ segments. len ( ) - 2 ] , parent_generics) ) ;
4971
- }
4972
- fn_segment = Some ( ( segments. last ( ) . unwrap ( ) , generics) ) ;
4973
- }
4974
-
4975
- _ => { }
4976
- }
4977
-
4978
- debug ! ( "type_segment={:?} fn_segment={:?}" , type_segment, fn_segment) ;
4979
-
4980
4940
// Now we have to compare the types that the user *actually*
4981
4941
// provided against the types that were *expected*. If the user
4982
4942
// did not provide any types, then we want to substitute inference
@@ -5004,14 +4964,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5004
4964
} ) . unwrap_or ( false ) ;
5005
4965
5006
4966
let def_id = def. def_id ( ) ;
5007
- let defs = self . tcx . generics_of ( def_id) ;
5008
- let count = defs . count ( ) ;
4967
+ let mut parent_defs = self . tcx . generics_of ( def_id) ;
4968
+ let count = parent_defs . count ( ) ;
5009
4969
let mut substs = if count <= 8 {
5010
4970
AccumulateVec :: Array ( ArrayVec :: new ( ) )
5011
4971
} else {
5012
4972
AccumulateVec :: Heap ( Vec :: with_capacity ( count) )
5013
4973
} ;
5014
- let mut parent_defs = defs;
5015
4974
let mut stack = vec ! [ ( def_id, parent_defs) ] ;
5016
4975
while let Some ( def_id) = parent_defs. parent {
5017
4976
parent_defs = self . tcx . generics_of ( def_id) ;
@@ -5030,7 +4989,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5030
4989
5031
4990
let infer_types = if let Some ( & PathSeg ( _, index) ) = path_segs
5032
4991
. iter ( )
5033
- . find ( |& PathSeg ( di , _) | * di == def_id) {
4992
+ . find ( |& PathSeg ( did , _) | * did == def_id) {
5034
4993
5035
4994
if let Some ( ref data) = segments[ index] . args {
5036
4995
let lifetime_offset = if infer_lifetimes[ & index] {
@@ -5048,7 +5007,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5048
5007
_ => bug ! ( "expected a lifetime arg" ) ,
5049
5008
}
5050
5009
GenericParamDefKind :: Type { .. } => match arg {
5051
- // A provided type parameter.
5052
5010
GenericArg :: Type ( ty) => self . to_ty ( ty) . into ( ) ,
5053
5011
_ => bug ! ( "expected a type arg" ) ,
5054
5012
}
@@ -5088,15 +5046,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5088
5046
5089
5047
// The things we are substituting into the type should not contain
5090
5048
// escaping late-bound regions, and nor should the base type scheme.
5091
- let ty = self . tcx . type_of ( def . def_id ( ) ) ;
5049
+ let ty = self . tcx . type_of ( def_id) ;
5092
5050
assert ! ( !substs. has_escaping_regions( ) ) ;
5093
5051
assert ! ( !ty. has_escaping_regions( ) ) ;
5094
5052
5095
5053
// Add all the obligations that are required, substituting and
5096
5054
// normalized appropriately.
5097
- let bounds = self . instantiate_bounds ( span, def . def_id ( ) , & substs) ;
5055
+ let bounds = self . instantiate_bounds ( span, def_id, & substs) ;
5098
5056
self . add_obligations_for_parameters (
5099
- traits:: ObligationCause :: new ( span, self . body_id , traits:: ItemObligation ( def . def_id ( ) ) ) ,
5057
+ traits:: ObligationCause :: new ( span, self . body_id , traits:: ItemObligation ( def_id) ) ,
5100
5058
& bounds) ;
5101
5059
5102
5060
// Substitute the values for the type parameters into the type of
@@ -5122,7 +5080,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5122
5080
}
5123
5081
}
5124
5082
5125
- self . check_rustc_args_require_const ( def . def_id ( ) , node_id, span) ;
5083
+ self . check_rustc_args_require_const ( def_id, node_id, span) ;
5126
5084
5127
5085
debug ! ( "instantiate_value_path: type of {:?} is {:?}" ,
5128
5086
node_id,
0 commit comments