Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/buck2
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 685d6ecde0c7a5a52b43b859ea44565d456dc613
Choose a base ref
..
head repository: facebook/buck2
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8ff38d05bf4be9e5f69b081a880904920a169281
Choose a head ref
Showing with 1,493 additions and 540 deletions.
  1. +1 −1 Cargo.toml
  2. +1 −1 README.md
  3. +1 −0 app/buck2_action_impl/BUCK
  4. +1 −0 app/buck2_action_impl/Cargo.toml
  5. +2 −2 app/buck2_action_impl/src/context/copy.rs
  6. +2 −2 app/buck2_action_impl/src/context/download.rs
  7. +2 −2 app/buck2_action_impl/src/context/dynamic_output.rs
  8. +2 −2 app/buck2_action_impl/src/context/run.rs
  9. +6 −4 app/buck2_action_impl/src/context/unsorted.rs
  10. +2 −2 app/buck2_action_impl/src/context/write.rs
  11. +9 −0 app/buck2_action_impl/src/dynamic/calculation.rs
  12. +3 −3 app/buck2_anon_target/src/starlark_defs.rs
  13. +2 −2 app/buck2_build_api/src/build/build_report.rs
  14. +12 −7 app/buck2_build_api/src/interpreter/rule_defs/context.rs
  15. +0 −3 app/buck2_build_api/src/interpreter/rule_defs/transitive_set.rs
  16. +2 −2 app/buck2_build_api/src/interpreter/rule_defs/transitive_set/transitive_set.rs
  17. +32 −23 app/buck2_build_api/src/interpreter/rule_defs/transitive_set/transitive_set_definition.rs
  18. +3 −0 app/buck2_build_signals/BUCK
  19. +3 −0 app/buck2_build_signals/Cargo.toml
  20. +1 −0 app/buck2_build_signals/src/lib.rs
  21. +98 −0 app/buck2_build_signals/src/node_key.rs
  22. +0 −3 app/buck2_build_signals_impl/BUCK
  23. +0 −3 app/buck2_build_signals_impl/Cargo.toml
  24. +17 −23 app/buck2_build_signals_impl/src/lib.rs
  25. +1 −1 app/buck2_bxl/src/bxl/starlark_defs/context.rs
  26. +7 −0 app/buck2_client_ctx/src/subscribers/recorder.rs
  27. +9 −1 app/buck2_client_ctx/src/subscribers/simpleconsole.rs
  28. +8 −1 app/buck2_client_ctx/src/subscribers/superconsole/system_warning.rs
  29. +6 −6 app/buck2_client_ctx/src/subscribers/system_warning.rs
  30. +1 −0 app/buck2_configured/BUCK
  31. +1 −0 app/buck2_configured/Cargo.toml
  32. +9 −0 app/buck2_configured/src/nodes/calculation.rs
  33. +20 −1 app/buck2_core/src/env/__macro_refs.rs
  34. +1 −1 app/buck2_core/src/fs/buck_out_path.rs
  35. +3 −0 app/buck2_data/data.proto
  36. +21 −7 app/buck2_event_observer/src/cold_build_detector.rs
  37. +22 −4 app/buck2_execute/src/execute/kind.rs
  38. +2 −1 app/buck2_execute/src/execute/result.rs
  39. +14 −14 app/buck2_execute_impl/src/executors/action_cache.rs
  40. +14 −14 app/buck2_execute_impl/src/executors/re.rs
  41. +2 −0 app/buck2_test/BUCK
  42. +2 −0 app/buck2_test/Cargo.toml
  43. +34 −2 app/buck2_test/src/orchestrator.rs
  44. +13 −1 app/buck2_test/src/session.rs
  45. +1 −0 app/buck2_test_api/BUCK
  46. +1 −0 app/buck2_test_api/Cargo.toml
  47. +69 −15 app/buck2_test_api/src/data.rs
  48. +1 −1 dice/dice/Cargo.toml
  49. +1 −0 dice/dice/src/api.rs
  50. +142 −0 dice/dice/src/api/demand.rs
  51. +8 −0 dice/dice/src/api/dyn_key.rs
  52. +8 −0 dice/dice/src/api/key.rs
  53. +29 −0 dice/dice/src/impls/key.rs
  54. +1 −0 dice/dice/src/lib.rs
  55. +1 −1 dice/fuzzy_dice/Cargo.toml
  56. +9 −9 flake.lock
  57. +7 −6 integrations/rust-project/src/buck.rs
  58. +2 −2 integrations/rust-project/src/cli/check.rs
  59. +3 −0 prelude/android/android_binary_native_library_rules.bzl
  60. +4 −1 prelude/android/tools/merge_sequence.py
  61. +1 −0 prelude/apple/apple_rules_impl.bzl
  62. +13 −12 prelude/apple/prebuilt_apple_framework.bzl
  63. +2 −0 prelude/cxx/cxx_toolchain.bzl
  64. +1 −0 prelude/cxx/cxx_toolchain_types.bzl
  65. +71 −17 prelude/cxx/dist_lto/darwin_dist_lto.bzl
  66. +159 −42 prelude/cxx/dist_lto/tools/dist_lto_planner_darwin.py
  67. +1 −0 prelude/cxx/link.bzl
  68. +3 −0 prelude/decls/android_rules.bzl
  69. +4 −5 prelude/haskell/haskell_ghci.bzl
  70. +3 −1 prelude/kotlin/kotlin_library.bzl
  71. +5 −4 prelude/kotlin/kotlincd_jar_creator.bzl
  72. +10 −9 prelude/python/compile.bzl
  73. +3 −3 prelude/python/make_py_package.bzl
  74. +2 −2 prelude/python/python.bzl
  75. +1 −1 prelude/python/python_library.bzl
  76. +46 −13 prelude/python/typecheck/batch.bxl
  77. +5 −1 prelude/python/typecheck/batch_files.bxl
  78. +103 −7 prelude/python/typing.bzl
  79. +14 −4 prelude/rust/rust-analyzer/check.bxl
  80. +1 −1 shim/third-party/rust/Cargo.toml
  81. +1 −1 starlark-rust/starlark/Cargo.toml
  82. +1 −1 starlark-rust/starlark_bin/Cargo.toml
  83. +1 −1 starlark-rust/starlark_lsp/Cargo.toml
  84. +1 −1 superconsole/Cargo.toml
  85. +4 −4 tests/core/build/test_critical_path_data/events.golden.json
  86. +64 −0 tests/core/bxl/BUCK
  87. +2 −2 tests/{e2e/bxl/test_bxl_configured_target.py → core/bxl/test_configured_target.py}
  88. 0 tests/{e2e/bxl/test_bxl_configured_target_data → core/bxl/test_configured_target_data}/.buckconfig
  89. 0 .../{e2e/bxl/test_bxl_configured_target_data → core/bxl/test_configured_target_data}/TARGETS.fixture
  90. 0 ...test_bxl_configured_target_data → core/bxl/test_configured_target_data}/bxl/configured_target.bxl
  91. 0 tests/{e2e/bxl/test_bxl_configured_target_data → core/bxl/test_configured_target_data}/defs.bzl
  92. 0 ...est_bxl_configured_target_data → core/bxl/test_configured_target_data}/transition/TARGETS.fixture
  93. 0 ...e/bxl/test_bxl_configured_target_data → core/bxl/test_configured_target_data}/transition/defs.bzl
  94. +4 −4 tests/{e2e/bxl/test_bxl_dynamic.py → core/bxl/test_dynamic.py}
  95. 0 tests/{e2e → core}/bxl/test_dynamic_data/.buckconfig
  96. 0 tests/{e2e → core}/bxl/test_dynamic_data/TARGETS.fixture
  97. 0 tests/{e2e → core}/bxl/test_dynamic_data/dynamic.bxl
  98. 0 tests/{e2e → core}/bxl/test_dynamic_data/happy_path_dynamic_ctx.golden.json
  99. 0 tests/{e2e → core}/bxl/test_dynamic_data/platforms/TARGETS.fixture
  100. 0 tests/{e2e → core}/bxl/test_dynamic_data/platforms/defs.bzl
  101. 0 tests/{e2e/bxl/test_bxl_target_universe_data → core/bxl/test_dynamic_data}/prelude/prelude.bzl
  102. 0 tests/{e2e → core}/bxl/test_dynamic_data/rules.bzl
  103. +3 −3 tests/{e2e → core}/bxl/test_not_bxl.py
  104. +5 −0 tests/core/bxl/test_not_bxl_data/.buckconfig
  105. 0 tests/{e2e/bxl/test_bxl_output_data → core/bxl/test_not_bxl_data}/.buckroot
  106. 0 tests/{e2e → core}/bxl/test_not_bxl_data/TARGETS.fixture
  107. 0 tests/{e2e/bxl → core/bxl/test_not_bxl_data}/not_bxl.bxl
  108. +4 −4 tests/{e2e/bxl/test_bxl_output.py → core/bxl/test_output.py}
  109. 0 tests/{e2e/bxl/test_bxl_output_data → core/bxl/test_output_data}/.buckconfig
  110. 0 tests/{e2e/bxl/test_bxl_typecheck_data/prelude.bzl → core/bxl/test_output_data/.buckroot}
  111. 0 tests/{e2e/bxl/test_bxl_output_data → core/bxl/test_output_data}/TARGETS.fixture
  112. 0 tests/{e2e/bxl/test_bxl_output_data → core/bxl/test_output_data}/caching.bxl
  113. +4 −4 tests/{e2e/bxl/test_bxl_target_universe.py → core/bxl/test_target_universe.py}
  114. +13 −0 tests/core/bxl/test_target_universe_data/.buckconfig
  115. 0 tests/{e2e/bxl/test_dynamic_data/prelude/prelude.bzl → core/bxl/test_target_universe_data/.buckroot}
  116. 0 ...test_bxl_target_universe_data → core/bxl/test_target_universe_data}/bad_buildfile/TARGETS.fixture
  117. +6 −8 ...l/test_bxl_target_universe_data → core/bxl/test_target_universe_data}/bad_targets/TARGETS.fixture
  118. +3 −6 .../test_bxl_target_universe_data → core/bxl/test_target_universe_data}/good_targets/TARGETS.fixture
  119. 0 tests/{e2e/bxl/test_bxl_target_universe_data → core/bxl/test_target_universe_data}/keep_going.bxl
  120. 0 .../test_bxl_target_universe_data → core/bxl/test_target_universe_data}/keep_going_invalid_input.bxl
  121. +1 −4 ...l/test_bxl_target_universe_data → core/bxl/test_target_universe_data}/not_visible/TARGETS.fixture
  122. +1 −3 ...bxl/test_bxl_target_universe_data → core/bxl/test_target_universe_data}/platforms/TARGETS.fixture
  123. +2 −0 tests/core/bxl/test_target_universe_data/some_cell/.buckconfig
  124. +2 −5 ...bxl/test_bxl_target_universe_data → core/bxl/test_target_universe_data}/some_cell/TARGETS.fixture
  125. 0 .../{e2e/bxl/test_bxl_target_universe_data → core/bxl/test_target_universe_data}/target_universe.bxl
  126. +1 −1 tests/{e2e → core}/bxl/test_type_names_and_symbols.py
  127. 0 tests/{e2e → core}/bxl/test_type_names_and_symbols_data/.buckconfig
  128. 0 tests/{e2e → core}/bxl/test_type_names_and_symbols_data/TARGETS.fixture
  129. 0 tests/{e2e → core}/bxl/test_type_names_and_symbols_data/bxl/check_type_names_and_symbols.bxl
  130. 0 tests/{e2e/bxl/test_not_bxl_data → core/bxl/test_type_names_and_symbols_data}/prelude.bzl
  131. +1 −1 tests/{e2e/bxl/test_bxl_typecheck.py → core/bxl/test_typecheck.py}
  132. 0 tests/{e2e/bxl/test_bxl_typecheck_data → core/bxl/test_typecheck_data}/.buckconfig
  133. 0 tests/{e2e/bxl/test_type_names_and_symbols_data → core/bxl/test_typecheck_data}/prelude.bzl
  134. 0 tests/{e2e/bxl/test_bxl_typecheck_data → core/bxl/test_typecheck_data}/test_typecheck.bxl
  135. +10 −0 tests/core/errors/test_formatting.py
  136. +5 −0 tests/core/errors/test_formatting_data/duplicate_target/TARGETS.fixture
  137. +9 −0 tests/core/errors/test_formatting_data/duplicate_target/make_target.bzl
  138. +18 −0 tests/core/errors/test_formatting_data/fixtures/test_duplicate_target.golden.stderr
  139. +24 −0 tests/core/errors/test_formatting_data/fixtures/test_duplicate_target_with_stacktrace.golden.stderr
  140. +6 −0 tests/core/interpreter/BUCK
  141. +23 −0 tests/core/interpreter/test_print.py
  142. +5 −0 tests/core/interpreter/test_print_data/.buckconfig
  143. 0 tests/core/interpreter/test_print_data/.buckroot
  144. +2 −0 tests/core/interpreter/test_print_data/TARGETS.fixture
  145. +15 −0 tests/core/query/uquery/test_uquery.py
  146. +12 −0 tests/core/targets_command/BUCK
  147. +20 −0 tests/core/targets_command/test_recursive.py
  148. +15 −0 tests/core/targets_command/test_recursive_data/.buckconfig
  149. 0 tests/core/targets_command/test_recursive_data/.buckroot
  150. +1 −0 tests/core/targets_command/test_recursive_data/ignored/TARGETS.fixture
  151. +50 −0 tests/core/targets_command/test_target_hashing.py
  152. +12 −0 tests/core/targets_command/test_target_hashing_data/.buckconfig
  153. 0 tests/core/targets_command/test_target_hashing_data/.buckroot
  154. +1 −0 tests/core/targets_command/test_target_hashing_data/bin/TARGETS.fixture
  155. +0 −72 tests/e2e/build/test_build_isolated.py
  156. +0 −61 tests/e2e/bxl/BUCK
  157. +0 −10 tests/e2e/bxl/test_bxl_target_universe_data/.buckconfig
  158. +0 −31 tests/e2e/bxl/test_bxl_target_universe_data/rules.bzl
  159. +0 −2 tests/e2e/bxl/test_bxl_target_universe_data/some_cell/.buckconfig
  160. +0 −6 tests/e2e/bxl/test_not_bxl_data/.buckconfig
  161. +14 −9 tests/e2e_util/buck_workspace.py
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -195,7 +195,7 @@ internment = { version = "0.8", features = ["arc"] }
inventory = "0.3.8"
ipnetwork = "0.20.0"
is_proc_translated = "0.1.1"
itertools = "0.10.3"
itertools = "0.13.0"
jemallocator = { version = "0.5.0", features = ["profiling"] }
lalrpop = { version = "0.19.7", artifact = "bin" }
lalrpop-util = "0.19.7"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
[CI]: https://github.com/facebook/buck2/actions/workflows/build-and-test.yml

<strong>
<a href="https://buck2.build">Homepage</a>&nbsp;&nbsp;&bull;&nbsp;&nbsp;<a href="https://buck2.build/docs/getting_started/">Getting Started</a>&nbsp;&nbsp;&bull;&nbsp;&nbsp;<a href="./CONTRIBUTING.md">Contributing</a>
<a href="https://buck2.build">Homepage</a>&nbsp;&nbsp;&bull;&nbsp;&nbsp;<a href="https://buck2.build/docs/about/getting_started/">Getting Started</a>&nbsp;&nbsp;&bull;&nbsp;&nbsp;<a href="./CONTRIBUTING.md">Contributing</a>
</strong>

---
1 change: 1 addition & 0 deletions app/buck2_action_impl/BUCK
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ rust_library(
"//buck2/app/buck2_action_metadata_proto:buck2_action_metadata_proto",
"//buck2/app/buck2_artifact:buck2_artifact",
"//buck2/app/buck2_build_api:buck2_build_api",
"//buck2/app/buck2_build_signals:buck2_build_signals",
"//buck2/app/buck2_common:buck2_common",
"//buck2/app/buck2_core:buck2_core",
"//buck2/app/buck2_data:buck2_data",
1 change: 1 addition & 0 deletions app/buck2_action_impl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ starlark_map = { workspace = true }
buck2_action_metadata_proto = { workspace = true }
buck2_artifact = { workspace = true }
buck2_build_api = { workspace = true }
buck2_build_signals = { workspace = true }
buck2_common = { workspace = true }
buck2_core = { workspace = true }
buck2_data = { workspace = true }
4 changes: 2 additions & 2 deletions app/buck2_action_impl/src/context/copy.rs
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ fn create_dir_tree<'v>(
let inputs = action.inputs();
let unioned_associated_artifacts = action.unioned_associated_artifacts();

let mut this = this.state();
let mut this = this.state()?;
let (declaration, output_artifact) =
this.get_or_declare_output(eval, output, OutputType::Directory)?;
this.register_action(inputs, indexset![output_artifact], action, None, None)?;
@@ -57,7 +57,7 @@ fn copy_file_impl<'v>(

let artifact = src.get_artifact_group()?;
let associated_artifacts = src.get_associated_artifacts();
let mut this = this.state();
let mut this = this.state()?;
let (declaration, output_artifact) = this.get_or_declare_output(eval, dest, output_type)?;

this.register_action(
4 changes: 2 additions & 2 deletions app/buck2_action_impl/src/context/download.rs
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ pub(crate) fn analysis_actions_methods_download(methods: &mut MethodsBuilder) {
#[starlark(require = named, default = false)] is_deferrable: bool,
eval: &mut Evaluator<'v, '_, '_>,
) -> anyhow::Result<ValueTyped<'v, StarlarkDeclaredArtifact>> {
let mut this = this.state();
let mut this = this.state()?;
let (declaration, output_artifact) =
this.get_or_declare_output(eval, output, OutputType::File)?;

@@ -106,7 +106,7 @@ pub(crate) fn analysis_actions_methods_download(methods: &mut MethodsBuilder) {
#[starlark(require = named, default = false)] is_directory: bool,
eval: &mut Evaluator<'v, '_, '_>,
) -> anyhow::Result<ValueTyped<'v, StarlarkDeclaredArtifact>> {
let mut registry = this.state();
let mut registry = this.state()?;

let digest = CasDigest::parse_digest(digest, this.digest_config.cas_digest_config())
.with_context(|| CasArtifactError::InvalidDigest(digest.to_owned()))?
4 changes: 2 additions & 2 deletions app/buck2_action_impl/src/context/dynamic_output.rs
Original file line number Diff line number Diff line change
@@ -172,7 +172,7 @@ pub(crate) fn analysis_actions_methods_dynamic_output(methods: &mut MethodsBuild
let attributes = this.attributes;
let plugins = this.plugins;

let mut this = this.state();
let mut this = this.state()?;

let execution_platform = this.actions.execution_platform.dupe();

@@ -217,7 +217,7 @@ pub(crate) fn analysis_actions_methods_dynamic_output(methods: &mut MethodsBuild
callable,
} = dynamic_actions;

let mut this = this.state();
let mut this = this.state()?;

let execution_platform = this.actions.execution_platform.dupe();

4 changes: 2 additions & 2 deletions app/buck2_action_impl/src/context/run.rs
Original file line number Diff line number Diff line change
@@ -300,7 +300,7 @@ pub(crate) fn analysis_actions_methods_run(methods: &mut MethodsBuilder) {
let metadata_param = match (metadata_env_var, metadata_path) {
(Some(env_var), Some(path)) => {
let path: ForwardRelativePathBuf = path.try_into()?;
this.state().claim_output_path(eval, &path)?;
this.state()?.claim_output_path(eval, &path)?;
Ok(Some(MetadataParameter { env_var, path }))
}
(Some(_), None) => Err(anyhow::anyhow!(RunActionError::MetadataPathMissing)),
@@ -344,7 +344,7 @@ pub(crate) fn analysis_actions_methods_run(methods: &mut MethodsBuilder) {
unique_input_inodes,
remote_execution_dependencies: re_dependencies,
};
this.state().register_action(
this.state()?.register_action(
artifacts.inputs,
artifacts.outputs,
action,
10 changes: 6 additions & 4 deletions app/buck2_action_impl/src/context/unsorted.rs
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ pub(crate) fn analysis_actions_methods_unsorted(builder: &mut MethodsBuilder) {
} else {
OutputType::FileOrDirectory
};
let artifact = this.state().declare_output(
let artifact = this.state()?.declare_output(
prefix,
filename,
output_type,
@@ -83,11 +83,13 @@ pub(crate) fn analysis_actions_methods_unsorted(builder: &mut MethodsBuilder) {
fn tset<'v>(
this: &AnalysisActions<'v>,
#[starlark(require = pos)] definition: FrozenValueTyped<'v, FrozenTransitiveSetDefinition>,
value: Option<Value<'v>>,
children: Option<ValueOfUnchecked<'v, StarlarkIter<Value<'v>>>>,
#[starlark(require = named)] value: Option<Value<'v>>,
#[starlark(require = named)] children: Option<
ValueOfUnchecked<'v, StarlarkIter<Value<'v>>>,
>,
eval: &mut Evaluator<'v, '_, '_>,
) -> starlark::Result<ValueTyped<'v, TransitiveSet<'v>>> {
let mut this = this.state();
let mut this = this.state()?;
this.create_transitive_set(definition, value, children.map(|v| v.get()), eval)
}

4 changes: 2 additions & 2 deletions app/buck2_action_impl/src/context/write.rs
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ pub(crate) fn analysis_actions_methods_write(methods: &mut MethodsBuilder) {
#[starlark(require = named, default = false)] absolute: bool,
eval: &mut Evaluator<'v, '_, '_>,
) -> anyhow::Result<impl AllocValue<'v>> {
let mut this = this.state();
let mut this = this.state()?;
let (declaration, output_artifact) =
this.get_or_declare_output(eval, output, OutputType::File)?;

@@ -209,7 +209,7 @@ pub(crate) fn analysis_actions_methods_write(methods: &mut MethodsBuilder) {
Ok(visitor.inputs)
}

let mut this = this.state();
let mut this = this.state()?;
let (declaration, output_artifact) =
this.get_or_declare_output(eval, output, OutputType::File)?;

9 changes: 9 additions & 0 deletions app/buck2_action_impl/src/dynamic/calculation.rs
Original file line number Diff line number Diff line change
@@ -16,7 +16,10 @@ use buck2_build_api::deferred::calculation::lookup_deferred_holder;
use buck2_build_api::dynamic::calculation::DynamicLambdaCalculation;
use buck2_build_api::dynamic::calculation::DynamicLambdaResult;
use buck2_build_api::dynamic::calculation::DYNAMIC_LAMBDA_CALCULATION_IMPL;
use buck2_build_signals::node_key::BuildSignalsNodeKey;
use buck2_build_signals::node_key::BuildSignalsNodeKeyImpl;
use dice::CancellationContext;
use dice::Demand;
use dice::DiceComputations;
use dice::Key;
use dupe::Dupe;
@@ -86,4 +89,10 @@ impl Key for DynamicLambdaDiceKey {
fn validity(x: &Self::Value) -> bool {
x.is_ok()
}

fn provide<'a>(&'a self, demand: &mut Demand<'a>) {
demand.provide_value_with(|| BuildSignalsNodeKey::new(self.dupe()));
}
}

impl BuildSignalsNodeKeyImpl for DynamicLambdaDiceKey {}
6 changes: 3 additions & 3 deletions app/buck2_anon_target/src/starlark_defs.rs
Original file line number Diff line number Diff line change
@@ -270,7 +270,7 @@ fn analysis_actions_methods_anon_target(builder: &mut MethodsBuilder) {
eval: &mut Evaluator<'v, '_, '_>,
) -> anyhow::Result<StarlarkAnonTarget<'v>> {
let anon_target_promise = eval.heap().alloc_typed(StarlarkPromise::new_unresolved());
let mut this = this.state();
let mut this = this.state()?;
let registry = AnonTargetsRegistry::downcast_mut(&mut *this.anon_targets)?;
let key = registry.anon_target_key(rule, attrs)?;
registry.register_one(anon_target_promise, key.clone())?;
@@ -294,7 +294,7 @@ fn analysis_actions_methods_anon_target(builder: &mut MethodsBuilder) {
)>,
eval: &mut Evaluator<'v, '_, '_>,
) -> anyhow::Result<StarlarkAnonTargets<'v>> {
let mut this = this.state();
let mut this = this.state()?;
let registry = AnonTargetsRegistry::downcast_mut(&mut *this.anon_targets)?;
let declaration_location = eval.call_stack_top_location();

@@ -338,7 +338,7 @@ fn analysis_actions_methods_anon_target(builder: &mut MethodsBuilder) {
artifact: ValueTyped<'v, StarlarkPromiseArtifact>,
short_path: &'v str,
) -> anyhow::Result<StarlarkPromiseArtifact> {
let mut this = this.state();
let mut this = this.state()?;
let promise = artifact.artifact.clone();

let short_path = ForwardRelativePathBuf::new(short_path.to_owned())?;
4 changes: 2 additions & 2 deletions app/buck2_build_api/src/build/build_report.rs
Original file line number Diff line number Diff line change
@@ -218,7 +218,7 @@ impl<'a> BuildReportCollector<'a> {
// to do a little iterator munging to achieve that ourselves
let results_by_unconfigured = configured
.iter()
.group_by(|x| x.0.target().unconfigured().dupe());
.chunk_by(|x| x.0.target().unconfigured().dupe());
let errors_by_unconfigured = other_errors
.iter()
.filter_map(|(l, e)| Some((l.as_ref()?.target().dupe(), e)));
@@ -294,7 +294,7 @@ impl<'a> BuildReportCollector<'a> {
.into_iter()
// We omit skipped targets here.
.filter_map(|(label, result)| Some((label, result.as_ref()?)))
.group_by(|x| x.0.target().dupe())
.chunk_by(|x| x.0.target().dupe())
{
let configured_report = self.collect_results_for_configured(target.dupe(), results);
if let Some(report) = unconfigured_report.as_mut() {
19 changes: 12 additions & 7 deletions app/buck2_build_api/src/interpreter/rule_defs/context.rs
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ use anyhow::Context;
use buck2_core::provider::label::ConfiguredProvidersLabel;
use buck2_core::provider::label::ProvidersName;
use buck2_core::target::configured_target_label::ConfiguredTargetLabel;
use buck2_error::BuckErrorContext;
use buck2_execute::digest_config::DigestConfig;
use buck2_interpreter::late_binding_ty::AnalysisContextReprLate;
use buck2_interpreter::types::configured_providers_label::StarlarkConfiguredProvidersLabel;
@@ -77,10 +78,14 @@ pub struct AnalysisActions<'v> {
}

impl<'v> AnalysisActions<'v> {
pub fn state(&self) -> RefMut<AnalysisRegistry<'v>> {
RefMut::map(self.state.borrow_mut(), |x| {
x.as_mut().expect("state to be present during execution")
})
pub fn state(&self) -> anyhow::Result<RefMut<AnalysisRegistry<'v>>> {
let state = self
.state
.try_borrow_mut()
.internal_error_anyhow("AnalysisActions.state is already borrowed")?;
RefMut::filter_map(state, |x| x.as_mut())
.ok()
.internal_error_anyhow("state to be present during execution")
}

pub async fn run_promises(
@@ -92,7 +97,7 @@ impl<'v> AnalysisActions<'v> {
// We need to loop here because running the promises evaluates promise.map, which might produce more promises.
// We keep going until there are no promises left.
loop {
let promises = self.state().take_promises();
let promises = self.state()?.take_promises();
if let Some(promises) = promises {
promises
.run_promises(dice, eval, description.clone())
@@ -113,7 +118,7 @@ impl<'v> AnalysisActions<'v> {
dice: &mut DiceComputations<'_>,
) -> anyhow::Result<()> {
let (short_path_assertions, consumer_analysis_artifacts) = {
let state = self.state();
let state = self.state()?;
(
state.short_path_assertions.clone(),
state.consumer_analysis_artifacts(),
@@ -239,7 +244,7 @@ impl<'v> AnalysisContext<'v> {
}

pub fn assert_no_promises(&self) -> anyhow::Result<()> {
self.actions.state().assert_no_promises()
self.actions.state()?.assert_no_promises()
}

/// Must take an `AnalysisContext` which has never had `take_state` called on it before.
Original file line number Diff line number Diff line change
@@ -88,9 +88,6 @@ pub(crate) enum TransitiveSetError {
error: anyhow::Error,
},

#[error("Expected args_projection `{}` function to take a single argument", .name)]
ProjectionSignatureError { name: String },

#[error("Error evaluating transitive set reduction {}", .name)]
ReductionError {
name: String,
Original file line number Diff line number Diff line change
@@ -411,7 +411,7 @@ impl<'v> TransitiveSet<'v> {
.iter()
.map(|(name, spec)| {
let projected_value = eval
.eval_function(spec.projection, &[value], &[])
.eval_function(spec.projection.get(), &[value], &[])
.map_err(|error| TransitiveSetError::ProjectionError {
error: BuckStarlarkError::new(error, OtherErrorHandling::InputError)
.into(),
@@ -449,7 +449,7 @@ impl<'v> TransitiveSet<'v> {
let value = value.unwrap_or_else(Value::new_none);

let reduced = eval
.eval_function(*reduce, &[children_values, value], &[])
.eval_function(reduce.get(), &[children_values, value], &[])
.map_err(|error| TransitiveSetError::ReductionError {
error: BuckStarlarkError::new(error, OtherErrorHandling::InputError).into(),
name: name.clone(),
Loading