@@ -45,7 +45,6 @@ use crate::cross_compile::try_alternate;
45
45
use crate :: paths;
46
46
use crate :: { diff, rustc_host} ;
47
47
use anyhow:: { bail, Result } ;
48
- use serde_json:: Value ;
49
48
use std:: fmt;
50
49
use std:: path:: Path ;
51
50
use std:: str;
@@ -654,81 +653,6 @@ pub(crate) fn match_with_without(
654
653
}
655
654
}
656
655
657
- /// Compares JSON object for approximate equality.
658
- /// You can use `[..]` wildcard in strings (useful for OS-dependent things such
659
- /// as paths). You can use a `"{...}"` string literal as a wildcard for
660
- /// arbitrary nested JSON (useful for parts of object emitted by other programs
661
- /// (e.g., rustc) rather than Cargo itself).
662
- pub ( crate ) fn find_json_mismatch (
663
- expected : & Value ,
664
- actual : & Value ,
665
- cwd : Option < & Path > ,
666
- ) -> Result < ( ) > {
667
- match find_json_mismatch_r ( expected, actual, cwd) {
668
- Some ( ( expected_part, actual_part) ) => bail ! (
669
- "JSON mismatch\n Expected:\n {}\n Was:\n {}\n Expected part:\n {}\n Actual part:\n {}\n " ,
670
- serde_json:: to_string_pretty( expected) . unwrap( ) ,
671
- serde_json:: to_string_pretty( & actual) . unwrap( ) ,
672
- serde_json:: to_string_pretty( expected_part) . unwrap( ) ,
673
- serde_json:: to_string_pretty( actual_part) . unwrap( ) ,
674
- ) ,
675
- None => Ok ( ( ) ) ,
676
- }
677
- }
678
-
679
- fn find_json_mismatch_r < ' a > (
680
- expected : & ' a Value ,
681
- actual : & ' a Value ,
682
- cwd : Option < & Path > ,
683
- ) -> Option < ( & ' a Value , & ' a Value ) > {
684
- use serde_json:: Value :: * ;
685
- match ( expected, actual) {
686
- ( & Number ( ref l) , & Number ( ref r) ) if l == r => None ,
687
- ( & Bool ( l) , & Bool ( r) ) if l == r => None ,
688
- ( & String ( ref l) , _) if l == "{...}" => None ,
689
- ( & String ( ref l) , & String ( ref r) ) => {
690
- if match_exact ( l, r, "" , "" , cwd) . is_err ( ) {
691
- Some ( ( expected, actual) )
692
- } else {
693
- None
694
- }
695
- }
696
- ( & Array ( ref l) , & Array ( ref r) ) => {
697
- if l. len ( ) != r. len ( ) {
698
- return Some ( ( expected, actual) ) ;
699
- }
700
-
701
- l. iter ( )
702
- . zip ( r. iter ( ) )
703
- . filter_map ( |( l, r) | find_json_mismatch_r ( l, r, cwd) )
704
- . next ( )
705
- }
706
- ( & Object ( ref l) , & Object ( ref r) ) => {
707
- let mut expected_entries = l. iter ( ) ;
708
- let mut actual_entries = r. iter ( ) ;
709
-
710
- loop {
711
- match ( expected_entries. next ( ) , actual_entries. next ( ) ) {
712
- ( None , None ) => return None ,
713
- ( Some ( ( expected_key, expected_value) ) , Some ( ( actual_key, actual_value) ) )
714
- if expected_key == actual_key =>
715
- {
716
- if let mismatch @ Some ( _) =
717
- find_json_mismatch_r ( expected_value, actual_value, cwd)
718
- {
719
- return mismatch;
720
- }
721
- }
722
- _ => return Some ( ( expected, actual) ) ,
723
- }
724
- }
725
- }
726
- ( & Null , & Null ) => None ,
727
- // Magic string literal `"{...}"` acts as wildcard for any sub-JSON.
728
- _ => Some ( ( expected, actual) ) ,
729
- }
730
- }
731
-
732
656
/// A single line string that supports `[..]` wildcard matching.
733
657
pub ( crate ) struct WildStr < ' a > {
734
658
has_meta : bool ,
0 commit comments