From 7cab2b20b347f476c2e22327f336f0be2c3531eb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 24 Mar 2018 09:51:33 -0700 Subject: [PATCH] Remove scoped_tls dependency This is causing [conflicts] with rebuilding upstream in rust-lang/rust, so remove this for now until we figure out a better solution. [conflicts]: https://github.com/rust-lang/rust/pull/49053#issuecomment-375906970 --- Cargo.toml | 1 - src/cargo/lib.rs | 2 -- src/cargo/sources/registry/index.rs | 7 +++++-- src/cargo/sources/registry/mod.rs | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ab89abfa6..c09a76995 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,6 @@ libgit2-sys = "0.7" log = "0.4" num_cpus = "1.0" same-file = "1" -scoped-tls = "0.1" semver = { version = "0.9.0", features = ["serde"] } serde = "1.0" serde_derive = "1.0" diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index b31d8a97c..e2857645f 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -31,8 +31,6 @@ extern crate libgit2_sys; extern crate log; extern crate num_cpus; extern crate same_file; -#[macro_use] -extern crate scoped_tls; extern crate semver; extern crate serde; #[macro_use] diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index eb07c24e8..857ed9bc6 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -148,8 +148,11 @@ impl<'cfg> RegistryIndex<'cfg> { features, yanked, links, - } = super::DEFAULT_ID.set(&self.source_id, || { - serde_json::from_str::(line) + } = super::DEFAULT_ID.with(|slot| { + *slot.borrow_mut() = Some(self.source_id.clone()); + let res = serde_json::from_str::(line); + drop(slot.borrow_mut().take()); + res })?; let pkgid = PackageId::new(&name, &vers, &self.source_id)?; let summary = Summary::new(pkgid, deps.inner, features, links)?; diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index cb5a90b5d..3a8183b28 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -159,6 +159,7 @@ //! ``` use std::borrow::Cow; +use std::cell::RefCell; use std::collections::BTreeMap; use std::fmt; use std::fs::File; @@ -454,7 +455,7 @@ impl<'cfg> Source for RegistrySource<'cfg> { // // If you're reading this and find this thread local funny, check to see if that // PR is merged. If it is then let's ditch this thread local! -scoped_thread_local!(static DEFAULT_ID: SourceId); +thread_local!(static DEFAULT_ID: RefCell> = Default::default()); impl<'de> de::Deserialize<'de> for DependencyList { fn deserialize(deserializer: D) -> Result @@ -506,7 +507,7 @@ fn parse_registry_dependency(dep: RegistryDependency) -> CargoResult let id = if let Some(registry) = registry { SourceId::for_registry(®istry.to_url()?)? } else { - DEFAULT_ID.with(|id| id.clone()) + DEFAULT_ID.with(|id| id.borrow().as_ref().unwrap().clone()) }; let mut dep = Dependency::parse_no_deprecated(&name, Some(&req), &id)?; -- 2.30.2