mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
Merge pull request #3922 from roc-lang/i3722
Only compile and run expects that belong to the same package
This commit is contained in:
commit
f918f16b0f
2 changed files with 34 additions and 16 deletions
|
@ -461,9 +461,11 @@ fn start_phase<'a>(
|
||||||
|
|
||||||
let derived_module = SharedDerivedModule::clone(&state.derived_module);
|
let derived_module = SharedDerivedModule::clone(&state.derived_module);
|
||||||
|
|
||||||
|
let build_expects = matches!(state.exec_mode, ExecutionMode::Test)
|
||||||
|
&& state.module_cache.expectations.contains_key(&module_id);
|
||||||
|
|
||||||
BuildTask::BuildPendingSpecializations {
|
BuildTask::BuildPendingSpecializations {
|
||||||
layout_cache,
|
layout_cache,
|
||||||
execution_mode: state.exec_mode,
|
|
||||||
module_id,
|
module_id,
|
||||||
module_timing,
|
module_timing,
|
||||||
solved_subs,
|
solved_subs,
|
||||||
|
@ -475,6 +477,7 @@ fn start_phase<'a>(
|
||||||
// TODO: awful, how can we get rid of the clone?
|
// TODO: awful, how can we get rid of the clone?
|
||||||
exposed_by_module: state.exposed_types.clone(),
|
exposed_by_module: state.exposed_types.clone(),
|
||||||
derived_module,
|
derived_module,
|
||||||
|
build_expects,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Phase::MakeSpecializations => {
|
Phase::MakeSpecializations => {
|
||||||
|
@ -1116,7 +1119,6 @@ enum BuildTask<'a> {
|
||||||
},
|
},
|
||||||
BuildPendingSpecializations {
|
BuildPendingSpecializations {
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
execution_mode: ExecutionMode,
|
|
||||||
layout_cache: LayoutCache<'a>,
|
layout_cache: LayoutCache<'a>,
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
imported_module_thunks: &'a [Symbol],
|
imported_module_thunks: &'a [Symbol],
|
||||||
|
@ -1127,6 +1129,7 @@ enum BuildTask<'a> {
|
||||||
exposed_by_module: ExposedByModule,
|
exposed_by_module: ExposedByModule,
|
||||||
abilities_store: AbilitiesStore,
|
abilities_store: AbilitiesStore,
|
||||||
derived_module: SharedDerivedModule,
|
derived_module: SharedDerivedModule,
|
||||||
|
build_expects: bool,
|
||||||
},
|
},
|
||||||
MakeSpecializations {
|
MakeSpecializations {
|
||||||
module_id: ModuleId,
|
module_id: ModuleId,
|
||||||
|
@ -2358,7 +2361,14 @@ fn update<'a>(
|
||||||
.type_problems
|
.type_problems
|
||||||
.insert(module_id, solved_module.problems);
|
.insert(module_id, solved_module.problems);
|
||||||
|
|
||||||
if !loc_expects.is_empty() {
|
let should_include_expects = !loc_expects.is_empty() && {
|
||||||
|
let modules = state.arc_modules.lock();
|
||||||
|
modules
|
||||||
|
.package_eq(module_id, state.root_id)
|
||||||
|
.expect("root or this module is not yet known - that's a bug!")
|
||||||
|
};
|
||||||
|
|
||||||
|
if should_include_expects {
|
||||||
let (path, _) = state.module_cache.sources.get(&module_id).unwrap();
|
let (path, _) = state.module_cache.sources.get(&module_id).unwrap();
|
||||||
|
|
||||||
let expectations = Expectations {
|
let expectations = Expectations {
|
||||||
|
@ -4808,7 +4818,6 @@ fn make_specializations<'a>(
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn build_pending_specializations<'a>(
|
fn build_pending_specializations<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
execution_mode: ExecutionMode,
|
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
imported_module_thunks: &'a [Symbol],
|
imported_module_thunks: &'a [Symbol],
|
||||||
home: ModuleId,
|
home: ModuleId,
|
||||||
|
@ -4821,6 +4830,7 @@ fn build_pending_specializations<'a>(
|
||||||
exposed_by_module: &ExposedByModule,
|
exposed_by_module: &ExposedByModule,
|
||||||
abilities_store: AbilitiesStore,
|
abilities_store: AbilitiesStore,
|
||||||
derived_module: SharedDerivedModule,
|
derived_module: SharedDerivedModule,
|
||||||
|
build_expects: bool,
|
||||||
) -> Msg<'a> {
|
) -> Msg<'a> {
|
||||||
let find_specializations_start = Instant::now();
|
let find_specializations_start = Instant::now();
|
||||||
|
|
||||||
|
@ -5067,11 +5077,8 @@ fn build_pending_specializations<'a>(
|
||||||
}
|
}
|
||||||
Expectation => {
|
Expectation => {
|
||||||
// skip expectations if we're not going to run them
|
// skip expectations if we're not going to run them
|
||||||
match execution_mode {
|
if !build_expects {
|
||||||
ExecutionMode::Test => { /* fall through */ }
|
continue;
|
||||||
ExecutionMode::Check
|
|
||||||
| ExecutionMode::Executable
|
|
||||||
| ExecutionMode::ExecutableIfCheck => continue,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark this symbol as a top-level thunk before any other work on the procs
|
// mark this symbol as a top-level thunk before any other work on the procs
|
||||||
|
@ -5143,11 +5150,8 @@ fn build_pending_specializations<'a>(
|
||||||
}
|
}
|
||||||
ExpectationFx => {
|
ExpectationFx => {
|
||||||
// skip expectations if we're not going to run them
|
// skip expectations if we're not going to run them
|
||||||
match execution_mode {
|
if !build_expects {
|
||||||
ExecutionMode::Test => { /* fall through */ }
|
continue;
|
||||||
ExecutionMode::Check
|
|
||||||
| ExecutionMode::Executable
|
|
||||||
| ExecutionMode::ExecutableIfCheck => continue,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark this symbol as a top-level thunk before any other work on the procs
|
// mark this symbol as a top-level thunk before any other work on the procs
|
||||||
|
@ -5422,7 +5426,6 @@ fn run_task<'a>(
|
||||||
)),
|
)),
|
||||||
BuildPendingSpecializations {
|
BuildPendingSpecializations {
|
||||||
module_id,
|
module_id,
|
||||||
execution_mode,
|
|
||||||
ident_ids,
|
ident_ids,
|
||||||
decls,
|
decls,
|
||||||
module_timing,
|
module_timing,
|
||||||
|
@ -5433,9 +5436,9 @@ fn run_task<'a>(
|
||||||
abilities_store,
|
abilities_store,
|
||||||
exposed_by_module,
|
exposed_by_module,
|
||||||
derived_module,
|
derived_module,
|
||||||
|
build_expects,
|
||||||
} => Ok(build_pending_specializations(
|
} => Ok(build_pending_specializations(
|
||||||
arena,
|
arena,
|
||||||
execution_mode,
|
|
||||||
solved_subs,
|
solved_subs,
|
||||||
imported_module_thunks,
|
imported_module_thunks,
|
||||||
module_id,
|
module_id,
|
||||||
|
@ -5448,6 +5451,7 @@ fn run_task<'a>(
|
||||||
&exposed_by_module,
|
&exposed_by_module,
|
||||||
abilities_store,
|
abilities_store,
|
||||||
derived_module,
|
derived_module,
|
||||||
|
build_expects,
|
||||||
)),
|
)),
|
||||||
MakeSpecializations {
|
MakeSpecializations {
|
||||||
module_id,
|
module_id,
|
||||||
|
|
|
@ -512,6 +512,20 @@ impl<'a> PackageModuleIds<'a> {
|
||||||
pub fn available_modules(&self) -> impl Iterator<Item = &PQModuleName> {
|
pub fn available_modules(&self) -> impl Iterator<Item = &PQModuleName> {
|
||||||
self.by_id.iter()
|
self.by_id.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true iff two modules belong to the same package.
|
||||||
|
/// Returns [None] if one module is unknown.
|
||||||
|
pub fn package_eq(&self, left: ModuleId, right: ModuleId) -> Option<bool> {
|
||||||
|
if left.is_builtin() ^ right.is_builtin() {
|
||||||
|
return Some(false);
|
||||||
|
}
|
||||||
|
let result = match (self.get_name(left)?, self.get_name(right)?) {
|
||||||
|
(PQModuleName::Unqualified(_), PQModuleName::Unqualified(_)) => true,
|
||||||
|
(PQModuleName::Qualified(pkg1, _), PQModuleName::Qualified(pkg2, _)) => pkg1 == pkg2,
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
Some(result)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores a mapping between ModuleId and InlinableString.
|
/// Stores a mapping between ModuleId and InlinableString.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue