@@ -88,16 +88,11 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
88
88
return Vec :: new ( ) ;
89
89
}
90
90
91
- let generics = cx. tcx . generics_of ( owner) ;
92
- let mut elision_has_failed_once_before = false ;
93
-
94
- let offset = if has_self { 1 } else { 0 } ;
95
- let mut clean_args = Vec :: with_capacity ( args. len ( ) . saturating_sub ( offset) ) ;
96
-
97
91
// If the container is a trait object type, the arguments won't contain the self type but the
98
92
// generics of the corresponding trait will. In such a case, prepend a dummy self type in order
99
93
// to align the arguments and parameters for the iteration below and to enable us to correctly
100
94
// instantiate the generic parameter default later.
95
+ let generics = cx. tcx . generics_of ( owner) ;
101
96
let args = if !has_self && generics. parent . is_none ( ) && generics. has_self {
102
97
has_self = true ;
103
98
[ cx. tcx . types . trait_object_dummy_self . into ( ) ]
@@ -109,6 +104,7 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
109
104
std:: borrow:: Cow :: from ( args)
110
105
} ;
111
106
107
+ let mut elision_has_failed_once_before = false ;
112
108
let clean_middle_arg = |( index, arg) : ( usize , & ty:: GenericArg < ' tcx > ) | {
113
109
// Elide the self type.
114
110
if has_self && index == 0 {
@@ -155,6 +151,8 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
155
151
}
156
152
} ;
157
153
154
+ let offset = if has_self { 1 } else { 0 } ;
155
+ let mut clean_args = Vec :: with_capacity ( args. len ( ) . saturating_sub ( offset) ) ;
158
156
clean_args. extend ( args. iter ( ) . enumerate ( ) . rev ( ) . filter_map ( clean_middle_arg) ) ;
159
157
clean_args. reverse ( ) ;
160
158
clean_args
0 commit comments