Skip to content

Commit 8545fbf

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Make AnalysisQueryResult struct
Summary: For code navigation. Clear now where `AnalysisQueryResult` is created for example. Reviewed By: JakobDegen Differential Revision: D51315032 fbshipit-source-id: 14cf33550ba56d5541a1be154cd2d6dca0106780
1 parent 64be60b commit 8545fbf

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

app/buck2_analysis/src/analysis/calculation.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ async fn resolve_queries_impl(
174174
))
175175
}
176176

177-
anyhow::Ok((query.to_owned(), Arc::new(query_results)))
177+
anyhow::Ok((
178+
query.to_owned(),
179+
Arc::new(AnalysisQueryResult {
180+
result: query_results,
181+
}),
182+
))
178183
}
179184
}))
180185
.await?;

app/buck2_analysis/src/analysis/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn resolve_query<'v>(
148148
match query_results.get(query) {
149149
None => Err(anyhow::anyhow!(AnalysisError::MissingQuery(query.to_owned())).into()),
150150
Some(x) => {
151-
for (_, y) in x.iter() {
151+
for (_, y) in x.result.iter() {
152152
// IMPORTANT: Anything given back to the user must be kept alive
153153
module.frozen_heap().add_reference(y.value().owner());
154154
}

app/buck2_analysis/src/attrs/resolve/attr_type/arg/query.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ impl ConfiguredQueryMacroBaseExt for QueryMacroBase<ConfiguredProvidersLabel> {
3030
match &self.expansion_type {
3131
QueryExpansion::Output => Ok(ResolvedQueryMacro::Outputs(
3232
query_result
33+
.result
3334
.iter()
3435
.map(|(_, providers)| {
3536
providers
@@ -42,6 +43,7 @@ impl ConfiguredQueryMacroBaseExt for QueryMacroBase<ConfiguredProvidersLabel> {
4243
)),
4344
QueryExpansion::Target => Ok(ResolvedQueryMacro::Targets(
4445
query_result
46+
.result
4547
.iter()
4648
.map(|(target, _)| target.dupe())
4749
.collect(),
@@ -54,6 +56,7 @@ impl ConfiguredQueryMacroBaseExt for QueryMacroBase<ConfiguredProvidersLabel> {
5456
None => " ".to_owned().into_boxed_str(),
5557
},
5658
list: query_result
59+
.result
5760
.iter()
5861
.map(|(target, providers)| {
5962
(

app/buck2_analysis/src/attrs/resolve/attr_type/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl ConfiguredQueryAttrExt for QueryAttr<ConfiguredProvidersLabel> {
2626
let query_results = ctx.resolve_query(&self.query.query)?;
2727
let mut dependencies = Vec::new();
2828

29-
for (target, providers) in &*query_results {
29+
for (target, providers) in &query_results.result {
3030
let providers_label =
3131
ConfiguredProvidersLabel::new(target.dupe(), ProvidersName::Default);
3232
if !self.providers.is_empty() {

app/buck2_analysis/src/attrs/resolve/ctx.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ use buck2_core::target::configured_target_label::ConfiguredTargetLabel;
1717
use starlark::environment::Module;
1818
use starlark::values::Heap;
1919

20-
pub type AnalysisQueryResult = Vec<(ConfiguredTargetLabel, FrozenProviderCollectionValue)>;
20+
pub struct AnalysisQueryResult {
21+
pub result: Vec<(ConfiguredTargetLabel, FrozenProviderCollectionValue)>,
22+
}
2123

2224
/// The context for attribute resolution. Provides access to the providers from
2325
/// dependents.

app/buck2_audit_server/src/analysis_queries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl AuditSubcommand for AuditAnalysisQueriesCommand {
7373
writeln!(stdout, "{}:", label)?;
7474
for (query, result) in &query_results {
7575
writeln!(stdout, " {}", query)?;
76-
for (target, providers) in &**result {
76+
for (target, providers) in &result.result {
7777
writeln!(stdout, " {}", target.unconfigured())?;
7878
if self.include_outputs {
7979
let outputs = providers

0 commit comments

Comments
 (0)