PDL: run the expected code through ‘rustfmt’ as well

Before we only formatted the newly generated code. The idea was to
compare this with the known-good code stored in the repository.

However, this requires us to carefully control the ‘rustfmt’
configuration: in particular, we need to copy a ‘rustfmt.toml’ file
into the directory from which we invoke ‘rustfmt’.

We can avoid this if we simply format both the new and the existing
code: this was the current settings of ‘rustfmt’ will take effect for
both pieces of code and we will be able to compare them for equality.

This change means that we don’t have to update any of the existing
known-good files if/when the common ‘rustfmt.toml’ files changes. This
change makes https://r.android.com/2096444 obsolete.

Test: atest 'pdl*'
Change-Id: I732cec8e08c8c8e8b70f40a1d074faecc89979ff
diff --git a/tools/pdl/Android.bp b/tools/pdl/Android.bp
index 651bb6d..155c76c 100644
--- a/tools/pdl/Android.bp
+++ b/tools/pdl/Android.bp
@@ -49,6 +49,5 @@
     ],
     data: [
         ":rustfmt",
-        "rustfmt.toml",
     ],
 }
diff --git a/tools/pdl/rustfmt.toml b/tools/pdl/rustfmt.toml
deleted file mode 120000
index 760eb84..0000000
--- a/tools/pdl/rustfmt.toml
+++ /dev/null
@@ -1 +0,0 @@
-../../rustfmt.toml
\ No newline at end of file
diff --git a/tools/pdl/src/generator.rs b/tools/pdl/src/generator.rs
index c600509..7abc8cc 100644
--- a/tools/pdl/src/generator.rs
+++ b/tools/pdl/src/generator.rs
@@ -506,7 +506,7 @@
     fn test_generate_preamble() {
         let actual_code = generate_preamble(Path::new("some/path/foo.pdl")).unwrap();
         let expected_code = include_str!("../test/generated/preamble.rs");
-        assert_eq_with_diff(&rustfmt(&actual_code), expected_code);
+        assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
     }
 
     #[test]
@@ -522,7 +522,7 @@
         let decl = &grammar.declarations[0];
         let actual_code = generate_decl(&grammar, &packets, &children, decl).unwrap();
         let expected_code = include_str!("../test/generated/packet_decl_empty.rs");
-        assert_eq_with_diff(&rustfmt(&actual_code), expected_code);
+        assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
     }
 
     #[test]
@@ -542,7 +542,7 @@
         let decl = &grammar.declarations[0];
         let actual_code = generate_decl(&grammar, &packets, &children, decl).unwrap();
         let expected_code = include_str!("../test/generated/packet_decl_simple_little_endian.rs");
-        assert_eq_with_diff(&rustfmt(&actual_code), expected_code);
+        assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
     }
 
     #[test]
@@ -562,6 +562,6 @@
         let decl = &grammar.declarations[0];
         let actual_code = generate_decl(&grammar, &packets, &children, decl).unwrap();
         let expected_code = include_str!("../test/generated/packet_decl_simple_big_endian.rs");
-        assert_eq_with_diff(&rustfmt(&actual_code), expected_code);
+        assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
     }
 }