about summary refs log tree commit diff
path: root/compiler/rustc_serialize/src/json
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-06-03 17:55:02 +0000
committerbors <bors@rust-lang.org>2022-06-03 17:55:02 +0000
commit7e9b92cb43a489b34e2bcb8d21f36198e02eedbc (patch)
treee2731c205d38c4d2c11fdb1789add435a21bab23 /compiler/rustc_serialize/src/json
parent9a74608543d499bcc7dd505e195e8bfab9447315 (diff)
parent5cc3593c17360edd92977301ca66551a45119619 (diff)
downloadrust-7e9b92cb43a489b34e2bcb8d21f36198e02eedbc.tar.gz
rust-7e9b92cb43a489b34e2bcb8d21f36198e02eedbc.zip
Auto merge of #85993 - bjorn3:serde_json, r=wesleywiser
Remove all json handling from rustc_serialize

Json is now handled using serde_json. Where appropriate I have replaced json usage with binary serialization (rmeta files) or manual string formatting (emcc linker arg generation).

This allowed for removing and simplifying a lot of code, which hopefully results in faster serialization/deserialization and faster compiles of rustc itself.

Where sensible we now use serde. Metadata and incr cache serialization keeps using a heavily modified (compared to crates.io) rustc-serialize version that in the future could probably be extended with zero-copy deserialization or other perf tricks that serde can't support due to supporting more than one serialization format.

Note that I had to remove `-Zast-json` and `-Zast-json-noexpand` as the relevant AST types don't implement `serde::Serialize`.

Fixes #40177

See also https://github.com/rust-lang/compiler-team/issues/418
Diffstat (limited to 'compiler/rustc_serialize/src/json')
-rw-r--r--compiler/rustc_serialize/src/json/tests.rs147
1 files changed, 0 insertions, 147 deletions
diff --git a/compiler/rustc_serialize/src/json/tests.rs b/compiler/rustc_serialize/src/json/tests.rs
deleted file mode 100644
index 01678fbf0b7..00000000000
--- a/compiler/rustc_serialize/src/json/tests.rs
+++ /dev/null
@@ -1,147 +0,0 @@
-// Benchmarks and tests that require private items
-
-extern crate test;
-use super::{from_str, Parser, Stack, StackElement};
-use std::string;
-use test::Bencher;
-
-#[test]
-fn test_stack() {
-    let mut stack = Stack::new();
-
-    assert!(stack.is_empty());
-    assert!(stack.is_empty());
-    assert!(!stack.last_is_index());
-
-    stack.push_index(0);
-    stack.bump_index();
-
-    assert!(stack.len() == 1);
-    assert!(stack.is_equal_to(&[StackElement::Index(1)]));
-    assert!(stack.starts_with(&[StackElement::Index(1)]));
-    assert!(stack.ends_with(&[StackElement::Index(1)]));
-    assert!(stack.last_is_index());
-    assert!(stack.get(0) == StackElement::Index(1));
-
-    stack.push_key("foo".to_string());
-
-    assert!(stack.len() == 2);
-    assert!(stack.is_equal_to(&[StackElement::Index(1), StackElement::Key("foo")]));
-    assert!(stack.starts_with(&[StackElement::Index(1), StackElement::Key("foo")]));
-    assert!(stack.starts_with(&[StackElement::Index(1)]));
-    assert!(stack.ends_with(&[StackElement::Index(1), StackElement::Key("foo")]));
-    assert!(stack.ends_with(&[StackElement::Key("foo")]));
-    assert!(!stack.last_is_index());
-    assert!(stack.get(0) == StackElement::Index(1));
-    assert!(stack.get(1) == StackElement::Key("foo"));
-
-    stack.push_key("bar".to_string());
-
-    assert!(stack.len() == 3);
-    assert!(stack.is_equal_to(&[
-        StackElement::Index(1),
-        StackElement::Key("foo"),
-        StackElement::Key("bar")
-    ]));
-    assert!(stack.starts_with(&[StackElement::Index(1)]));
-    assert!(stack.starts_with(&[StackElement::Index(1), StackElement::Key("foo")]));
-    assert!(stack.starts_with(&[
-        StackElement::Index(1),
-        StackElement::Key("foo"),
-        StackElement::Key("bar")
-    ]));
-    assert!(stack.ends_with(&[StackElement::Key("bar")]));
-    assert!(stack.ends_with(&[StackElement::Key("foo"), StackElement::Key("bar")]));
-    assert!(stack.ends_with(&[
-        StackElement::Index(1),
-        StackElement::Key("foo"),
-        StackElement::Key("bar")
-    ]));
-    assert!(!stack.last_is_index());
-    assert!(stack.get(0) == StackElement::Index(1));
-    assert!(stack.get(1) == StackElement::Key("foo"));
-    assert!(stack.get(2) == StackElement::Key("bar"));
-
-    stack.pop();
-
-    assert!(stack.len() == 2);
-    assert!(stack.is_equal_to(&[StackElement::Index(1), StackElement::Key("foo")]));
-    assert!(stack.starts_with(&[StackElement::Index(1), StackElement::Key("foo")]));
-    assert!(stack.starts_with(&[StackElement::Index(1)]));
-    assert!(stack.ends_with(&[StackElement::Index(1), StackElement::Key("foo")]));
-    assert!(stack.ends_with(&[StackElement::Key("foo")]));
-    assert!(!stack.last_is_index());
-    assert!(stack.get(0) == StackElement::Index(1));
-    assert!(stack.get(1) == StackElement::Key("foo"));
-}
-
-#[bench]
-fn bench_streaming_small(b: &mut Bencher) {
-    b.iter(|| {
-        let mut parser = Parser::new(
-            r#"{
-                "a": 1.0,
-                "b": [
-                    true,
-                    "foo\nbar",
-                    { "c": {"d": null} }
-                ]
-            }"#
-            .chars(),
-        );
-        loop {
-            match parser.next() {
-                None => return,
-                _ => {}
-            }
-        }
-    });
-}
-#[bench]
-fn bench_small(b: &mut Bencher) {
-    b.iter(|| {
-        let _ = from_str(
-            r#"{
-            "a": 1.0,
-            "b": [
-                true,
-                "foo\nbar",
-                { "c": {"d": null} }
-            ]
-        }"#,
-        );
-    });
-}
-
-fn big_json() -> string::String {
-    let mut src = "[\n".to_string();
-    for _ in 0..500 {
-        src.push_str(
-            r#"{ "a": true, "b": null, "c":3.1415, "d": "Hello world", "e": \
-                        [1,2,3]},"#,
-        );
-    }
-    src.push_str("{}]");
-    return src;
-}
-
-#[bench]
-fn bench_streaming_large(b: &mut Bencher) {
-    let src = big_json();
-    b.iter(|| {
-        let mut parser = Parser::new(src.chars());
-        loop {
-            match parser.next() {
-                None => return,
-                _ => {}
-            }
-        }
-    });
-}
-#[bench]
-fn bench_large(b: &mut Bencher) {
-    let src = big_json();
-    b.iter(|| {
-        let _ = from_str(&src);
-    });
-}