@@ -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_arg = |( index, & arg) : ( usize , & ty:: GenericArg < ' tcx > ) | {
113
109
// Elide the self type.
114
110
if has_self && index == 0 {
@@ -152,6 +148,8 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
152
148
}
153
149
} ;
154
150
151
+ let offset = if has_self { 1 } else { 0 } ;
152
+ let mut clean_args = Vec :: with_capacity ( args. len ( ) . saturating_sub ( offset) ) ;
155
153
clean_args. extend ( args. iter ( ) . enumerate ( ) . rev ( ) . filter_map ( clean_arg) ) ;
156
154
clean_args. reverse ( ) ;
157
155
clean_args
0 commit comments