@@ -1293,40 +1293,51 @@ fn compare_values<'a>(
12931293 rhs : ValueRef ,
12941294 rhs_t : ty:: t )
12951295 -> Result < ' a > {
1296+ fn compare_str < ' a > ( cx : & ' a Block < ' a > ,
1297+ lhs : ValueRef ,
1298+ rhs : ValueRef ,
1299+ rhs_t : ty:: t )
1300+ -> Result < ' a > {
1301+ let did = langcall ( cx, None ,
1302+ format ! ( "comparison of `{}`" , cx. ty_to_str( rhs_t) ) ,
1303+ StrEqFnLangItem ) ;
1304+ let result = callee:: trans_lang_call ( cx, did, [ lhs, rhs] , None ) ;
1305+ Result {
1306+ bcx : result. bcx ,
1307+ val : bool_to_i1 ( result. bcx , result. val )
1308+ }
1309+ }
1310+
12961311 let _icx = push_ctxt ( "compare_values" ) ;
12971312 if ty:: type_is_scalar ( rhs_t) {
1298- let rs = compare_scalar_types ( cx, lhs, rhs, rhs_t, ast:: BiEq ) ;
1299- return rslt ( rs. bcx , rs. val ) ;
1313+ let rs = compare_scalar_types ( cx, lhs, rhs, rhs_t, ast:: BiEq ) ;
1314+ return rslt ( rs. bcx , rs. val ) ;
13001315 }
13011316
13021317 match ty:: get ( rhs_t) . sty {
1303- ty:: ty_str( ty:: VstoreUniq ) => {
1304- let scratch_lhs = alloca ( cx, val_ty ( lhs) , "__lhs" ) ;
1305- Store ( cx, lhs, scratch_lhs) ;
1306- let scratch_rhs = alloca ( cx, val_ty ( rhs) , "__rhs" ) ;
1307- Store ( cx, rhs, scratch_rhs) ;
1308- let did = langcall ( cx, None ,
1309- format ! ( "comparison of `{}`" , cx. ty_to_str( rhs_t) ) ,
1310- UniqStrEqFnLangItem ) ;
1311- let result = callee:: trans_lang_call ( cx, did, [ scratch_lhs, scratch_rhs] , None ) ;
1312- Result {
1313- bcx : result. bcx ,
1314- val : bool_to_i1 ( result. bcx , result. val )
1315- }
1316- }
1317- ty:: ty_str( _) => {
1318- let did = langcall ( cx, None ,
1319- format ! ( "comparison of `{}`" , cx. ty_to_str( rhs_t) ) ,
1320- StrEqFnLangItem ) ;
1321- let result = callee:: trans_lang_call ( cx, did, [ lhs, rhs] , None ) ;
1322- Result {
1323- bcx : result. bcx ,
1324- val : bool_to_i1 ( result. bcx , result. val )
1318+ ty:: ty_uniq( t) => match ty:: get ( t) . sty {
1319+ ty:: ty_str( None ) => {
1320+ let scratch_lhs = alloca ( cx, val_ty ( lhs) , "__lhs" ) ;
1321+ Store ( cx, lhs, scratch_lhs) ;
1322+ let scratch_rhs = alloca ( cx, val_ty ( rhs) , "__rhs" ) ;
1323+ Store ( cx, rhs, scratch_rhs) ;
1324+ let did = langcall ( cx, None ,
1325+ format ! ( "comparison of `{}`" , cx. ty_to_str( rhs_t) ) ,
1326+ UniqStrEqFnLangItem ) ;
1327+ let result = callee:: trans_lang_call ( cx, did, [ scratch_lhs, scratch_rhs] , None ) ;
1328+ Result {
1329+ bcx : result. bcx ,
1330+ val : bool_to_i1 ( result. bcx , result. val )
1331+ }
13251332 }
1326- }
1327- _ => {
1328- cx. sess ( ) . bug ( "only scalars and strings supported in compare_values" ) ;
1329- }
1333+ _ => cx. sess ( ) . bug ( "only scalars and strings supported in compare_values" ) ,
1334+ } ,
1335+ ty:: ty_rptr( _, mt) => match ty:: get ( mt. ty ) . sty {
1336+ ty:: ty_str( None ) => compare_str ( cx, lhs, rhs, rhs_t) ,
1337+ _ => cx. sess ( ) . bug ( "only scalars and strings supported in compare_values" ) ,
1338+ } ,
1339+ ty:: ty_str( Some ( _) ) => compare_str ( cx, lhs, rhs, rhs_t) ,
1340+ _ => cx. sess ( ) . bug ( "only scalars and strings supported in compare_values" ) ,
13301341 }
13311342}
13321343
0 commit comments