Skip to content

Remove deserialize #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions src/bootstrap/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use serde::Deserialize;
use serde::de::{self, Deserializer, Visitor};

use std::any::{Any, TypeId};
use std::borrow::Borrow;
use std::cell::RefCell;
Expand All @@ -29,29 +26,6 @@ use builder::Step;

pub struct Interned<T>(usize, PhantomData<*const T>);

impl<'de> Deserialize<'de> for Interned<String> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>
{
struct StrVisitor;

impl<'de> Visitor<'de> for StrVisitor {
type Value = &'de str;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a str")
}

fn visit_borrowed_str<E>(self, value: &'de str) -> Result<&'de str, E>
where E: de::Error
{
Ok(value)
}
}

Ok(INTERNER.intern_str(deserializer.deserialize_str(StrVisitor)?))
}
}
impl Default for Interned<String> {
fn default() -> Self {
INTERNER.intern_string(String::default())
Expand Down
19 changes: 10 additions & 9 deletions src/bootstrap/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use build_helper::output;
use serde_json;

use {Build, Crate};
use cache::Interned;
use cache::INTERNER;

#[derive(Deserialize)]
struct Output {
Expand All @@ -27,7 +27,7 @@ struct Output {
#[derive(Deserialize)]
struct Package {
id: String,
name: Interned<String>,
name: String,
version: String,
source: Option<String>,
manifest_path: String,
Expand Down Expand Up @@ -66,15 +66,16 @@ fn build_krate(build: &mut Build, krate: &str) {
let mut id2name = HashMap::new();
for package in output.packages {
if package.source.is_none() {
id2name.insert(package.id, package.name);
let name = INTERNER.intern_string(package.name);
id2name.insert(package.id, name);
let mut path = PathBuf::from(package.manifest_path);
path.pop();
build.crates.insert(package.name, Crate {
build_step: format!("build-crate-{}", package.name),
doc_step: format!("doc-crate-{}", package.name),
test_step: format!("test-crate-{}", package.name),
bench_step: format!("bench-crate-{}", package.name),
name: package.name,
build.crates.insert(name, Crate {
build_step: format!("build-crate-{}", name),
doc_step: format!("doc-crate-{}", name),
test_step: format!("test-crate-{}", name),
bench_step: format!("bench-crate-{}", name),
name: name,
version: package.version,
deps: Vec::new(),
path: path,
Expand Down