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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions compiler/pavex_test_runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use guppy::graph::PackageGraph;
use itertools::Itertools;
use libtest_mimic::{Arguments, Conclusion, Failed, Trial};
use pavex_cli_shell::try_init_shell;
use pavexc::rustdoc::CrateCollection;
use pavexc::rustdoc::{CrateCollection, CrateCollectionExt};
use pavexc::{DEFAULT_DOCS_TOOLCHAIN, DiagnosticSink};
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use sha2::Digest;
Expand Down Expand Up @@ -429,7 +429,7 @@ fn warm_up_rustdoc_cache(
// We want to ensure that all invocations of `pavexc generate` hit the cache
// thus avoiding the need to invoke `rustdoc` and acquire a contentious
// lock over the target directory.
let crate_collection = CrateCollection::new(
let crate_collection = CrateCollection::new_pavex(
DEFAULT_DOCS_TOOLCHAIN.to_owned(),
package_graph.clone(),
package_graph.workspace().root().to_string(),
Expand Down Expand Up @@ -488,7 +488,7 @@ fn warm_up_rustdoc_cache(
let n_packages = package_ids.len();
println!("Pre-computing JSON documentation for {n_packages} crates",);
crate_collection
.batch_compute_crates(package_ids.into_iter())
.compute_batch(package_ids.into_iter())
.context("Failed to warm rustdoc JSON cache")?;
println!(
"Pre-computed JSON documentation for {n_packages} crates in {} seconds",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use crate::utils::comma_separated_list;
use guppy::graph::PackageGraph;
use indexmap::IndexSet;
use miette::{NamedSource, Severity};
use rustdoc_processor::queries::CrateRegistry;
use rustdoc_types::ItemEnum;
use syn::spanned::Spanned;

Expand Down
2 changes: 1 addition & 1 deletion compiler/pavexc/src/compiler/analyses/components/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::diagnostic::{ParsedSourceFile, Registration, TargetSpan};
use crate::language::{
Callable, FQPath, FQPathSegment, FQQualifiedSelf, Lifetime, PathTypeExt, Type, TypeReference,
};
use crate::rustdoc::CrateCollection;
use crate::rustdoc::{CrateCollection, CrateCollectionExt};
use ahash::{HashMap, HashMapExt, HashSet};
use guppy::graph::PackageGraph;
use indexmap::IndexSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::diagnostic::invalid_prebuilt_type;
use crate::compiler::analyses::prebuilt_types::PrebuiltTypeDb;
use crate::{
DiagnosticSink, compiler::analyses::computations::ComputationDb, rustdoc::CrateCollection,
DiagnosticSink,
compiler::analyses::computations::ComputationDb,
rustdoc::{CrateCollection, CrateCollectionExt},
};
use pavexc_attr_parser::AnnotationProperties;

Expand Down Expand Up @@ -113,7 +115,8 @@ pub(crate) fn resolve_annotation_coordinates(
}
Err(e) => {
let path_display = krate.import_index.items[&item.id]
.canonical_path().to_vec()
.canonical_path()
.to_vec()
.join("::");
invalid_config_type(e, &path_display, component_id, aux, diagnostics)
}
Expand Down Expand Up @@ -152,7 +155,8 @@ pub(crate) fn resolve_annotation_coordinates(
}
Err(e) => {
let path_display = krate.import_index.items[&item.id]
.canonical_path().to_vec()
.canonical_path()
.to_vec()
.join("::");
invalid_prebuilt_type(e, &path_display, component_id, aux, diagnostics)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use crate::{
use pavex_bp_schema::{CloningPolicy, Lifecycle, Lint, LintSetting};
use pavexc_attr_parser::{AnnotationKind, AnnotationProperties};
use rustdoc_ext::RustdocKindExt;
use rustdoc_processor::queries::CrateRegistry;
use rustdoc_types::{GenericArgs, Item, ItemEnum};

/// An id pointing at the coordinates of an annotated component.
Expand Down Expand Up @@ -374,7 +373,8 @@ fn intern_annotated(
}
Err(e) => {
let path_display = krate.import_index.items[&item.id]
.canonical_path().to_vec()
.canonical_path()
.to_vec()
.join("::");
invalid_config_type(e, &path_display, config_id, aux, diagnostics)
}
Expand Down Expand Up @@ -416,7 +416,8 @@ fn intern_annotated(
}
Err(e) => {
let path_display = krate.import_index.items[&item.id]
.canonical_path().to_vec()
.canonical_path()
.to_vec()
.join("::");
invalid_prebuilt_type(e, &path_display, prebuilt_id, aux, diagnostics)
}
Expand Down Expand Up @@ -481,9 +482,7 @@ fn annotated_item2type(
return Err(());
}
};
let Ok(krate) =
krate_collection.get_or_compute_crate_by_package_id(&imported_id.package_id)
else {
let Ok(krate) = krate_collection.get_or_compute(&imported_id.package_id) else {
return Err(());
};
(
Expand Down Expand Up @@ -619,8 +618,8 @@ fn rustdoc_free_fn2callable(
unreachable!("Expected a function item");
};

let canonical_path_segments: Vec<String> = krate.import_index.items[&item.id]
.canonical_path().to_vec();
let canonical_path_segments: Vec<String> =
krate.import_index.items[&item.id].canonical_path().to_vec();
// A representation of the path that will be used in error paths
let path_display = canonical_path_segments.join("::");

Expand Down Expand Up @@ -827,7 +826,8 @@ fn rustdoc_method2callable(
})
} else {
let canonical_path_segments: Vec<String> = krate.import_index.items[&attached_to]
.canonical_path().to_vec();
.canonical_path()
.to_vec();
let method_name = method_item.name.clone().expect("Method without a name");
let n = canonical_path_segments.len();
MethodPath::Inherent(InherentMethodPath {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ fn precompute_crate_docs<'a, J>(
package_ids.extend(imported_package_ids);
let package_ids = package_ids.iter().map(|&p| p.to_owned());

if let Err(e) = krate_collection.bootstrap_collection(package_ids.clone()) {
if let Err(e) = krate_collection.bootstrap(package_ids.clone()) {
let e = anyhow::anyhow!(e).context(
"I failed to compute the JSON documentation for one or more crates in the workspace.",
);
Expand Down
1 change: 0 additions & 1 deletion compiler/pavexc/src/compiler/path_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use crate::diagnostic::DiagnosticSink;
use crate::language::{GenericArgument, Type};
use crate::rustdoc::{CrateCollection, GlobalItemId};
use crate::utils::comma_separated_list;
use rustdoc_processor::queries::CrateRegistry;

use super::analyses::route_path::RoutePath;
use super::traits::assert_trait_is_implemented;
Expand Down
1 change: 0 additions & 1 deletion compiler/pavexc/src/compiler/resolvers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use crate::language::{
};
use crate::rustdoc::{CannotGetCrateData, CrateCollection, ResolvedItem};
use rustdoc_ext::RustdocKindExt;
use rustdoc_processor::queries::CrateRegistry;

#[derive(Default)]
pub(crate) struct GenericBindings {
Expand Down
1 change: 0 additions & 1 deletion compiler/pavexc/src/compiler/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use rustdoc_types::{GenericParamDefKind, ItemEnum, Type as RustdocType};
use crate::compiler::resolvers::resolve_type;
use crate::language::{PathType, Type};
use crate::rustdoc::{Crate, CrateCollection};
use rustdoc_processor::queries::CrateRegistry;

use super::resolvers::GenericBindings;

Expand Down
1 change: 0 additions & 1 deletion compiler/pavexc/src/diagnostic/callable_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::rustdoc::CrateCollection;
use guppy::graph::PackageGraph;
use miette::{NamedSource, SourceSpan};
use pavex_cli_diagnostic::AnnotatedSource;
use rustdoc_processor::queries::CrateRegistry;
use rustdoc_types::ItemEnum;
use syn::spanned::Spanned;

Expand Down
10 changes: 5 additions & 5 deletions compiler/pavexc/src/language/fq_path_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use crate::language::callable_path::{CallPathGenericArgument, CallPathLifetime,
use crate::language::krate_name::dependency_name2package_id;
use crate::language::resolved_type::{Array, GenericArgument, Slice};
use crate::language::{CallPath, InvalidCallPath, RawPointer, Tuple, Type, TypeReference};
use crate::rustdoc::{CannotGetCrateData, CrateCollection, GlobalItemId, ResolvedItem};
use crate::rustdoc::{
CannotGetCrateData, CrateCollection, CrateCollectionExt, GlobalItemId, ResolvedItem,
};
use rustdoc_ext::RustdocKindExt;
use rustdoc_processor::queries::CrateRegistry;

use super::RawIdentifiers;
use super::fq_path::*;
Expand Down Expand Up @@ -268,7 +269,7 @@ pub fn find_rustdoc_callable_items<'a>(
path: &FQPath,
krate_collection: &'a CrateCollection,
) -> Result<Result<CallableItem<'a>, UnknownPath>, CannotGetCrateData> {
let krate = krate_collection.get_or_compute_crate_by_package_id(&path.package_id)?;
let krate = krate_collection.get_or_compute(&path.package_id)?;

let path_without_generics: Vec<_> = path
.segments
Expand Down Expand Up @@ -354,8 +355,7 @@ pub fn find_rustdoc_callable_items<'a>(
unreachable!()
}
};
let search_krate =
krate_collection.get_or_compute_crate_by_package_id(&parent_item.item_id.package_id)?;
let search_krate = krate_collection.get_or_compute(&parent_item.item_id.package_id)?;
for child_id in children_ids {
let child = search_krate.get_item_by_local_type_id(child_id);
match &child.inner {
Expand Down
29 changes: 29 additions & 0 deletions compiler/pavexc/src/rustdoc/cache.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! Thin wrapper around `rustdoc_processor` that integrates with pavexc's types.

use guppy::graph::PackageGraph;

use rustdoc_processor::cache::RustdocGlobalFsCache;

/// Construct a [`RustdocGlobalFsCache`] pre-configured with Pavex's cache fingerprint
/// and default cache directory (`~/.pavex/rustdoc/cache`).
pub(crate) fn pavex_rustdoc_cache<A: Default + bincode::Decode<()>>(
toolchain_name: &str,
cache_workspace_package_docs: bool,
package_graph: &PackageGraph,
) -> Result<RustdocGlobalFsCache<A>, anyhow::Error> {
let fingerprint = format!(
"{}-{}",
rustdoc_processor::CRATE_VERSION,
env!("RUSTDOC_CACHE_SOURCE_HASH")
);
let cache_dir = xdg_home::home_dir()
.ok_or_else(|| anyhow::anyhow!("Failed to get the user's home directory"))?
.join(".pavex/rustdoc/cache");
RustdocGlobalFsCache::new(
&fingerprint,
toolchain_name,
cache_workspace_package_docs,
package_graph,
&cache_dir,
)
}
Loading
Loading