Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: generate auto derive attributes correctly #240

Merged
merged 1 commit into from
Apr 22, 2024
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
149 changes: 78 additions & 71 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pilota-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pilota-build"
version = "0.11.2"
version = "0.11.3"
edition = "2021"
description = "Compile thrift and protobuf idl into rust code at compile-time."
documentation = "https://docs.rs/pilota-build"
Expand Down
8 changes: 7 additions & 1 deletion pilota-build/src/middle/workspace_graph.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use petgraph::{graph::NodeIndex, Graph};
use petgraph::{algo::has_path_connecting, graph::NodeIndex, Graph};
use rustc_hash::FxHashMap;

use super::{
Expand Down Expand Up @@ -77,4 +77,10 @@ impl WorkspaceGraph {
id_map,
}
}

pub fn is_nested(&self, a: DefId, b: DefId) -> bool {
let a = self.node_map[&a];
let b = self.node_map[&b];
has_path_connecting(&self.graph, a, b, None)
}
}
7 changes: 4 additions & 3 deletions pilota-build/src/plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,11 @@ where
.count();

if paths_can_derive.iter().any(|(_, p)| *p == CanDerive::No) {
delayed.iter().for_each(|def_id| {
self.can_derive.insert(*def_id, CanDerive::No);
delayed.iter().for_each(|delayed_def_id| {
if cx.workspace_graph().is_nested(*delayed_def_id, def_id) {
self.can_derive.insert(*delayed_def_id, CanDerive::No);
}
});

CanDerive::No
} else if delayed_count > 0 {
delayed.insert(def_id);
Expand Down
Loading
Loading