Skip to content

Commit d4bd588

Browse files
committed
Auto merge of #5239 - alexcrichton:remove-scoped-tls, r=matklad
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]: rust-lang/rust#49053 (comment)
2 parents 93b0b12 + 7cab2b2 commit d4bd588

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ libgit2-sys = "0.7"
4141
log = "0.4"
4242
num_cpus = "1.0"
4343
same-file = "1"
44-
scoped-tls = "0.1"
4544
semver = { version = "0.9.0", features = ["serde"] }
4645
serde = "1.0"
4746
serde_derive = "1.0"

src/cargo/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ extern crate libgit2_sys;
3131
extern crate log;
3232
extern crate num_cpus;
3333
extern crate same_file;
34-
#[macro_use]
35-
extern crate scoped_tls;
3634
extern crate semver;
3735
extern crate serde;
3836
#[macro_use]

src/cargo/sources/registry/index.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ impl<'cfg> RegistryIndex<'cfg> {
148148
features,
149149
yanked,
150150
links,
151-
} = super::DEFAULT_ID.set(&self.source_id, || {
152-
serde_json::from_str::<RegistryPackage>(line)
151+
} = super::DEFAULT_ID.with(|slot| {
152+
*slot.borrow_mut() = Some(self.source_id.clone());
153+
let res = serde_json::from_str::<RegistryPackage>(line);
154+
drop(slot.borrow_mut().take());
155+
res
153156
})?;
154157
let pkgid = PackageId::new(&name, &vers, &self.source_id)?;
155158
let summary = Summary::new(pkgid, deps.inner, features, links)?;

src/cargo/sources/registry/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
//! ```
160160
161161
use std::borrow::Cow;
162+
use std::cell::RefCell;
162163
use std::collections::BTreeMap;
163164
use std::fmt;
164165
use std::fs::File;
@@ -454,7 +455,7 @@ impl<'cfg> Source for RegistrySource<'cfg> {
454455
//
455456
// If you're reading this and find this thread local funny, check to see if that
456457
// PR is merged. If it is then let's ditch this thread local!
457-
scoped_thread_local!(static DEFAULT_ID: SourceId);
458+
thread_local!(static DEFAULT_ID: RefCell<Option<SourceId>> = Default::default());
458459

459460
impl<'de> de::Deserialize<'de> for DependencyList {
460461
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
@@ -506,7 +507,7 @@ fn parse_registry_dependency(dep: RegistryDependency) -> CargoResult<Dependency>
506507
let id = if let Some(registry) = registry {
507508
SourceId::for_registry(&registry.to_url()?)?
508509
} else {
509-
DEFAULT_ID.with(|id| id.clone())
510+
DEFAULT_ID.with(|id| id.borrow().as_ref().unwrap().clone())
510511
};
511512

512513
let mut dep = Dependency::parse_no_deprecated(&name, Some(&req), &id)?;

0 commit comments

Comments
 (0)