Skip to content
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
19 changes: 10 additions & 9 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version = "0.0.0"
dependencies = [
"compiler_builtins 0.0.0",
"core 0.0.0",
"rand 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand Down Expand Up @@ -433,7 +433,7 @@ dependencies = [
name = "core"
version = "0.0.0"
dependencies = [
"rand 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand Down Expand Up @@ -475,7 +475,7 @@ dependencies = [
"crossbeam-epoch 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
]

Expand Down Expand Up @@ -1444,7 +1444,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
Expand Down Expand Up @@ -1644,7 +1644,7 @@ dependencies = [

[[package]]
name = "rand"
version = "0.5.4"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -1767,6 +1767,7 @@ dependencies = [
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ordslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"racer 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-analysis 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -2191,7 +2192,7 @@ version = "0.0.0"
dependencies = [
"graphviz 0.0.0",
"log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_fs_util 0.0.0",
Expand Down Expand Up @@ -2627,7 +2628,7 @@ dependencies = [
"panic_abort 0.0.0",
"panic_unwind 0.0.0",
"profiler_builtins 0.0.0",
"rand 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_asan 0.0.0",
"rustc_lsan 0.0.0",
"rustc_msan 0.0.0",
Expand Down Expand Up @@ -2794,7 +2795,7 @@ version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -3262,7 +3263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5"
"checksum racer 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4bc3847329b20ff5ba56c298938c179ae9911af15c9c10553f683b65164533"
"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
"checksum rand 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "12397506224b2f93e6664ffc4f664b29be8208e5157d3d90b44f09b5fae470ea"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
"checksum rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edecf0f94da5551fc9b492093e30b041a891657db7940ee221f9d2f66e82eef2"
"checksum rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80e811e76f1dbf68abf87a759083d34600017fc4e10b6bd5ad84a700f9dba4b1"
"checksum rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d24ad214285a7729b174ed6d3bcfcb80177807f959d95fafd5bfc5c4f201ac8"
Expand Down
43 changes: 22 additions & 21 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,18 @@ impl OutputTypes {
// DO NOT switch BTreeMap or BTreeSet out for an unsorted container type! That
// would break dependency tracking for commandline arguments.
#[derive(Clone, Hash)]
pub struct Externs(BTreeMap<String, BTreeSet<String>>);
pub struct Externs(BTreeMap<String, BTreeSet<Option<String>>>);

impl Externs {
pub fn new(data: BTreeMap<String, BTreeSet<String>>) -> Externs {
pub fn new(data: BTreeMap<String, BTreeSet<Option<String>>>) -> Externs {
Externs(data)
}

pub fn get(&self, key: &str) -> Option<&BTreeSet<String>> {
pub fn get(&self, key: &str) -> Option<&BTreeSet<Option<String>>> {
self.0.get(key)
}

pub fn iter<'a>(&'a self) -> BTreeMapIter<'a, String, BTreeSet<String>> {
pub fn iter<'a>(&'a self) -> BTreeMapIter<'a, String, BTreeSet<Option<String>>> {
self.0.iter()
}
}
Expand Down Expand Up @@ -2169,6 +2169,8 @@ pub fn build_session_options_and_crate_config(
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
let test = matches.opt_present("test");

let is_unstable_enabled = nightly_options::is_unstable_enabled(matches);

prints.extend(matches.opt_strs("print").into_iter().map(|s| match &*s {
"crate-name" => PrintRequest::CrateName,
"file-names" => PrintRequest::FileNames,
Expand All @@ -2182,15 +2184,13 @@ pub fn build_session_options_and_crate_config(
"tls-models" => PrintRequest::TlsModels,
"native-static-libs" => PrintRequest::NativeStaticLibs,
"target-spec-json" => {
if nightly_options::is_unstable_enabled(matches) {
if is_unstable_enabled {
PrintRequest::TargetSpec
} else {
early_error(
error_format,
&format!(
"the `-Z unstable-options` flag must also be passed to \
enable the target-spec-json print option"
),
"the `-Z unstable-options` flag must also be passed to \
enable the target-spec-json print option",
);
}
}
Expand Down Expand Up @@ -2220,18 +2220,19 @@ pub fn build_session_options_and_crate_config(
Some(s) => s,
None => early_error(error_format, "--extern value must not be empty"),
};
let location = match parts.next() {
Some(s) => s,
None => early_error(
let location = parts.next().map(|s| s.to_string());
if location.is_none() && !is_unstable_enabled {
early_error(
error_format,
"--extern value must be of the format `foo=bar`",
),
"the `-Z unstable-options` flag must also be passed to \
enable `--extern crate_name` without `=path`",
);
};

externs
.entry(name.to_string())
.or_default()
.insert(location.to_string());
.insert(location);
}

let crate_name = matches.opt_str("crate-name");
Expand Down Expand Up @@ -2687,33 +2688,33 @@ mod tests {
v1.externs = Externs::new(mk_map(vec![
(
String::from("a"),
mk_set(vec![String::from("b"), String::from("c")]),
mk_set(vec![Some(String::from("b")), Some(String::from("c"))]),
),
(
String::from("d"),
mk_set(vec![String::from("e"), String::from("f")]),
mk_set(vec![Some(String::from("e")), Some(String::from("f"))]),
),
]));

v2.externs = Externs::new(mk_map(vec![
(
String::from("d"),
mk_set(vec![String::from("e"), String::from("f")]),
mk_set(vec![Some(String::from("e")), Some(String::from("f"))]),
),
(
String::from("a"),
mk_set(vec![String::from("b"), String::from("c")]),
mk_set(vec![Some(String::from("b")), Some(String::from("c"))]),
),
]));

v3.externs = Externs::new(mk_map(vec![
(
String::from("a"),
mk_set(vec![String::from("b"), String::from("c")]),
mk_set(vec![Some(String::from("b")), Some(String::from("c"))]),
),
(
String::from("d"),
mk_set(vec![String::from("f"), String::from("e")]),
mk_set(vec![Some(String::from("f")), Some(String::from("e"))]),
),
]));

Expand Down
6 changes: 5 additions & 1 deletion src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
.collect(),
hir,
def_path_hash_to_def_id,
queries: query::Queries::new(providers, on_disk_query_result_cache),
queries: query::Queries::new(
providers,
extern_providers,
on_disk_query_result_cache,
),
rcache: Lock::new(FxHashMap()),
selection_cache: traits::SelectionCache::new(),
evaluation_cache: traits::EvaluationCache::new(),
Expand Down
11 changes: 10 additions & 1 deletion src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,12 @@ macro_rules! define_queries_inner {
impl<$tcx> Queries<$tcx> {
pub fn new(
providers: IndexVec<CrateNum, Providers<$tcx>>,
fallback_extern_providers: Providers<$tcx>,
on_disk_cache: OnDiskCache<'tcx>,
) -> Self {
Queries {
providers,
fallback_extern_providers: Box::new(fallback_extern_providers),
on_disk_cache,
$($name: Lock::new(QueryCache::new())),*
}
Expand Down Expand Up @@ -818,7 +820,13 @@ macro_rules! define_queries_inner {
#[inline]
fn compute(tcx: TyCtxt<'_, 'tcx, '_>, key: Self::Key) -> Self::Value {
__query_compute::$name(move || {
let provider = tcx.queries.providers[key.query_crate()].$name;
let provider = tcx.queries.providers.get(key.query_crate())
// HACK(eddyb) it's possible crates may be loaded after
// the query engine is created, and because crate loading
// is not yet integrated with the query engine, such crates
// would be be missing appropriate entries in `providers`.
.unwrap_or(&tcx.queries.fallback_extern_providers)
.$name;
provider(tcx.global_tcx(), key)
})
}
Expand Down Expand Up @@ -899,6 +907,7 @@ macro_rules! define_queries_struct {
pub(crate) on_disk_cache: OnDiskCache<'tcx>,

providers: IndexVec<CrateNum, Providers<$tcx>>,
fallback_extern_providers: Box<Providers<$tcx>>,

$($(#[$attr])* $name: Lock<QueryCache<$tcx, queries::$name<$tcx>>>,)*
}
Expand Down
Loading