@@ -136,17 +136,49 @@ impl Constant {
136136 ( & Self :: F64 ( l) , & Self :: F64 ( r) ) => l. partial_cmp ( & r) ,
137137 ( & Self :: F32 ( l) , & Self :: F32 ( r) ) => l. partial_cmp ( & r) ,
138138 ( & Self :: Bool ( ref l) , & Self :: Bool ( ref r) ) => Some ( l. cmp ( r) ) ,
139- ( & Self :: Tuple ( ref l) , & Self :: Tuple ( ref r) ) | ( & Self :: Vec ( ref l) , & Self :: Vec ( ref r) ) => iter:: zip ( l, r)
140- . map ( |( li, ri) | Self :: partial_cmp ( tcx, cmp_type, li, ri) )
141- . find ( |r| r. map_or ( true , |o| o != Ordering :: Equal ) )
142- . unwrap_or_else ( || Some ( l. len ( ) . cmp ( & r. len ( ) ) ) ) ,
139+ ( & Self :: Tuple ( ref l) , & Self :: Tuple ( ref r) ) if l. len ( ) == r. len ( ) => match * cmp_type. kind ( ) {
140+ ty:: Tuple ( tys) if tys. len ( ) == l. len ( ) => l
141+ . iter ( )
142+ . zip ( r)
143+ . zip ( tys)
144+ . map ( |( ( li, ri) , cmp_type) | Self :: partial_cmp ( tcx, cmp_type, li, ri) )
145+ . find ( |r| r. map_or ( true , |o| o != Ordering :: Equal ) )
146+ . unwrap_or_else ( || Some ( l. len ( ) . cmp ( & r. len ( ) ) ) ) ,
147+ _ => None ,
148+ } ,
149+ ( & Self :: Vec ( ref l) , & Self :: Vec ( ref r) ) => {
150+ let cmp_type = match * cmp_type. kind ( ) {
151+ ty:: Array ( ty, _) | ty:: Slice ( ty) => ty,
152+ _ => return None ,
153+ } ;
154+ iter:: zip ( l, r)
155+ . map ( |( li, ri) | Self :: partial_cmp ( tcx, cmp_type, li, ri) )
156+ . find ( |r| r. map_or ( true , |o| o != Ordering :: Equal ) )
157+ . unwrap_or_else ( || Some ( l. len ( ) . cmp ( & r. len ( ) ) ) )
158+ } ,
143159 ( & Self :: Repeat ( ref lv, ref ls) , & Self :: Repeat ( ref rv, ref rs) ) => {
144- match Self :: partial_cmp ( tcx, cmp_type, lv, rv) {
160+ match Self :: partial_cmp (
161+ tcx,
162+ match * cmp_type. kind ( ) {
163+ ty:: Array ( ty, _) => ty,
164+ _ => return None ,
165+ } ,
166+ lv,
167+ rv,
168+ ) {
145169 Some ( Equal ) => Some ( ls. cmp ( rs) ) ,
146170 x => x,
147171 }
148172 } ,
149- ( & Self :: Ref ( ref lb) , & Self :: Ref ( ref rb) ) => Self :: partial_cmp ( tcx, cmp_type, lb, rb) ,
173+ ( & Self :: Ref ( ref lb) , & Self :: Ref ( ref rb) ) => Self :: partial_cmp (
174+ tcx,
175+ match * cmp_type. kind ( ) {
176+ ty:: Ref ( _, ty, _) => ty,
177+ _ => return None ,
178+ } ,
179+ lb,
180+ rb,
181+ ) ,
150182 // TODO: are there any useful inter-type orderings?
151183 _ => None ,
152184 }
0 commit comments