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
68 changes: 51 additions & 17 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ rustdoc_processor = { path = "rustdoc/rustdoc_processor", version = "0.2.10" }
rustdoc_resolver = { path = "rustdoc/rustdoc_resolver", version = "0.2.10" }
pavexc_annotations = { path = "compiler/pavexc_annotations", version = "0.2.10" }
persist_if_changed = { path = "compiler/persist_if_changed", version = "0.2.10" }
# Our own fork of `rustdoc-types` to minimise (de)ser overhead.
rustdoc-types = { path = "rustdoc/rustdoc_types", version = "0.2.10", features = ["rustc-hash"], package = "rustdoc_types" }

rustdoc-types = { version = "0.57.3", features = ["rustc-hash", "rkyv_0_8" ] }
vergen-gitcl = { version = "1.0.8", features = ["build"] }
ahash = "0.8"
anstyle = "1.0.13"
Expand Down
2 changes: 1 addition & 1 deletion compiler/pavexc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ mod utils;

/// The Rust toolchain used by `pavexc` to generate JSON docs, unless
/// overridden by the user.
pub static DEFAULT_DOCS_TOOLCHAIN: &str = "nightly-2025-12-15";
pub static DEFAULT_DOCS_TOOLCHAIN: &str = "nightly-2026-05-01";
3 changes: 2 additions & 1 deletion compiler/pavexc/src/rustdoc/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
use guppy::graph::PackageGraph;

use rustdoc_processor::cache::RustdocGlobalFsCache;
use serde::de::DeserializeOwned;

/// 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<()>>(
pub(crate) fn pavex_rustdoc_cache<A: Default + DeserializeOwned>(
toolchain_name: &str,
cache_workspace_package_docs: bool,
package_graph: &PackageGraph,
Expand Down
1 change: 0 additions & 1 deletion compiler/pavexc_annotations/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::borrow::Cow;
use std::collections::BTreeSet;

use pavexc_attr_parser::{AnnotationKind, AnnotationProperties};
use rustdoc_ext::ItemEnumExt;
use rustdoc_types::{Enum, Item, ItemEnum, Struct, Trait};

use crate::errors::AnnotationError;
Expand Down
8 changes: 3 additions & 5 deletions compiler/pavexc_annotations/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use pavex_bp_schema::CreatedAt;
use pavexc_attr_parser::AnnotationProperties;

/// All the annotated items for a given package.
#[derive(
Default, Debug, Clone, serde::Serialize, serde::Deserialize, bincode::Encode, bincode::Decode,
)]
#[derive(Default, Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct AnnotatedItems {
item_id2details: BTreeMap<rustdoc_types::Id, AnnotatedItem>,
annotation_id2item_id: BTreeMap<String, rustdoc_types::Id>,
Expand Down Expand Up @@ -63,7 +61,7 @@ pub struct IdConflict {
}

/// An item decorated with a Pavex annotation.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, bincode::Encode, bincode::Decode)]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct AnnotatedItem {
/// The identifier of the annotated item.
pub id: rustdoc_types::Id,
Expand All @@ -74,7 +72,7 @@ pub struct AnnotatedItem {
}

/// Information about the `impl` block the item belongs to, if any.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, bincode::Encode, bincode::Decode)]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ImplInfo {
/// The `id` of the item this `impl` block was attached to.
/// For inherent methods, that's the `Self` type.
Expand Down
3 changes: 2 additions & 1 deletion rustdoc/rustdoc_processor/src/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod toolchain;
pub mod utils;

pub use entry::{CacheEntry, SecondaryIndexes};
use serde::de::DeserializeOwned;
pub use utils::RkyvCowBytes;

use std::collections::BTreeSet;
Expand Down Expand Up @@ -126,7 +127,7 @@ impl<'a> RustdocCacheKey<'a> {
}
}

impl<A: bincode::Decode<()> + Default> RustdocGlobalFsCache<A> {
impl<A: DeserializeOwned + Default> RustdocGlobalFsCache<A> {
/// Initialize a new instance of the cache.
///
/// The `cache_fingerprint` is used to determine the database file name.
Expand Down
5 changes: 3 additions & 2 deletions rustdoc/rustdoc_processor/src/cache/third_party.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use camino::Utf8Path;
use guppy::graph::feature::StandardFeatures;
use guppy::graph::{PackageGraph, PackageMetadata};
use rusqlite::params;
use serde::de::DeserializeOwned;
use tracing::instrument;
use tracing_log_error::log_error;

Expand Down Expand Up @@ -44,14 +45,14 @@ impl ThirdPartyCrateCache {
level=tracing::Level::DEBUG,
fields(crate.id = %package_metadata.id(), cache_key = tracing::field::Empty, hit = tracing::field::Empty)
)]
pub(super) fn get<A: bincode::Decode<()> + Default>(
pub(super) fn get<A: DeserializeOwned + Default>(
&self,
package_metadata: &PackageMetadata,
cargo_fingerprint: &str,
connection: &rusqlite::Connection,
package_graph: &PackageGraph,
) -> Result<Option<HydratedCacheEntry<A>>, anyhow::Error> {
fn _get<A: bincode::Decode<()> + Default>(
fn _get<A: DeserializeOwned + Default>(
package_metadata: &PackageMetadata,
cargo_fingerprint: &str,
connection: &rusqlite::Connection,
Expand Down
25 changes: 15 additions & 10 deletions rustdoc/rustdoc_processor/src/cache/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::borrow::Cow;

use guppy::PackageId;
use rusqlite::params;
use serde::de::DeserializeOwned;
use tracing::instrument;

use super::entry::{CacheEntry, SecondaryIndexes};
Expand Down Expand Up @@ -31,7 +32,7 @@ impl ToolchainCache {
level=tracing::Level::DEBUG,
fields(crate.name = %name)
)]
pub(super) fn get<A: bincode::Decode<()> + Default>(
pub(super) fn get<A: DeserializeOwned + Default>(
&self,
name: &str,
cargo_fingerprint: &str,
Expand Down Expand Up @@ -167,17 +168,20 @@ impl CacheEntry<'_> {
/// We hydrate all mappings eagerly, but we avoid re-hydrating the item index eagerly,
/// since it can be quite large and deserialization can be slow for large crates.
/// The item index is stored as rkyv-serialized bytes for zero-copy access.
pub fn hydrate<A: bincode::Decode<()> + Default>(
pub fn hydrate<A: DeserializeOwned + Default>(
self,
package_id: PackageId,
) -> Result<HydratedCacheEntry<A>, anyhow::Error> {
use anyhow::Context;

let crate_data = CrateData {
root_item_id: rustdoc_types::Id(self.root_item_id.to_owned()),
external_crates: bincode::decode_from_slice(&self.external_crates, BINCODE_CONFIG)
.context("Failed to deserialize external_crates")?
.0,
external_crates: bincode::serde::decode_from_slice(
&self.external_crates,
BINCODE_CONFIG,
)
.context("Failed to deserialize external_crates")?
.0,
paths: CrateItemPaths::Lazy(LazyCrateItemPaths {
bytes: self.paths.into_owned(),
}),
Expand All @@ -191,16 +195,17 @@ impl CacheEntry<'_> {
};

let import_index =
bincode::decode_from_slice(&secondary_indexes.import_index, BINCODE_CONFIG)
bincode::serde::decode_from_slice(&secondary_indexes.import_index, BINCODE_CONFIG)
.context("Failed to deserialize import_index")?
.0;

let re_exports = bincode::decode_from_slice(&secondary_indexes.re_exports, BINCODE_CONFIG)
.context("Failed to deserialize re-exports")?
.0;
let re_exports =
bincode::serde::decode_from_slice(&secondary_indexes.re_exports, BINCODE_CONFIG)
.context("Failed to deserialize re-exports")?
.0;

let annotated_items: A = if let Some(data) = secondary_indexes.annotated_items {
bincode::decode_from_slice(&data, BINCODE_CONFIG)
bincode::serde::decode_from_slice(&data, BINCODE_CONFIG)
.context("Failed to deserialize annotated_items")?
.0
} else {
Expand Down
8 changes: 2 additions & 6 deletions rustdoc/rustdoc_processor/src/indexing/import_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use std::collections::BTreeSet;
use ahash::HashMap;

/// An index of all importable items in a crate.
#[derive(
Debug, Clone, Default, serde::Serialize, serde::Deserialize, bincode::Encode, bincode::Decode,
)]
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct ImportIndex {
/// A mapping that keeps track of all modules defined in the current crate.
///
Expand All @@ -24,9 +22,7 @@ pub struct ImportIndex {
}

/// An entry in [`ImportIndex`].
#[derive(
Debug, Clone, Default, serde::Serialize, serde::Deserialize, bincode::Encode, bincode::Decode,
)]
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct ImportIndexEntry {
/// All the public paths that can be used to import the item.
pub public_paths: BTreeSet<SortablePath>,
Expand Down
2 changes: 1 addition & 1 deletion rustdoc/rustdoc_processor/src/indexing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::queries::Crate;
/// `#[pavex(...)]` attributes, while a plain consumer may use `()` annotations.
pub trait CrateIndexer: Send + Sync {
/// The annotation payload stored alongside each indexed crate.
type Annotations: Default + Send + Sync + serde::Serialize + bincode::Decode<()>;
type Annotations: Default + Send + Sync + serde::Serialize + serde::de::DeserializeOwned;

/// Index a freshly-computed rustdoc JSON crate.
fn index_raw(
Expand Down
4 changes: 1 addition & 3 deletions rustdoc/rustdoc_processor/src/indexing/re_exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ use crate::queries::Crate;
use rustdoc_ext::GlobalItemId;

/// Track re-exports of types (or entire modules!) from other crates.
#[derive(
Debug, Clone, Default, serde::Serialize, serde::Deserialize, bincode::Encode, bincode::Decode,
)]
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct ExternalReExports {
/// Key: the path of the re-exported type in the current crate.
/// Value: the id of the `rustdoc` item of kind `use` that performed the re-export.
Expand Down
23 changes: 0 additions & 23 deletions rustdoc/rustdoc_types/Cargo.toml

This file was deleted.

Loading
Loading