Skip to content

Conversation

@antonok-edm
Copy link

Resolves Case 2 of #231

I ran into this issue when trying to generate zbus bindings for ModemManager, which has four such naming collisions. This resolves the issue there and should help for others who have commented on #231.

Copy link
Contributor

@zeenix zeenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM otherwise. Thanks!

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 15, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing antonok-edm:avoid-generating-signal-changed-collisions (7c8eee1) with main (a79634a)

Summary

✅ 22 untouched benchmarks

@antonok-edm antonok-edm force-pushed the avoid-generating-signal-changed-collisions branch from ddf72f5 to b8ea635 Compare January 16, 2026 19:59
@antonok-edm antonok-edm requested a review from zeenix January 16, 2026 19:59
Copy link
Contributor

@zeenix zeenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nitpicks resolved and we're good to merge. :)

@antonok-edm antonok-edm force-pushed the avoid-generating-signal-changed-collisions branch from b8ea635 to 29cb297 Compare January 17, 2026 20:06
Copy link
Contributor

@zeenix zeenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very close, I promise :)

@antonok-edm antonok-edm force-pushed the avoid-generating-signal-changed-collisions branch from 29cb297 to b34e04d Compare January 19, 2026 21:07
@antonok-edm antonok-edm requested a review from zeenix January 19, 2026 21:10
When given an interface definition with a property named `Foo` and a
signal named `FooChanged`, `zbus_xmlgen` would generate duplicate
`receive_foo_changed` methods, causing compilation errors.

In practice, the colliding `*Changed` signal is used to override the
behavior of the property's implicit change signal, so it's preferable to
use the overridden one and leave off the implicit rather than keeping it
as a compilation error.

Resolves `Case 2` of z-galaxy#231
@antonok-edm antonok-edm force-pushed the avoid-generating-signal-changed-collisions branch from b34e04d to 7c8eee1 Compare January 19, 2026 21:59
Copy link
Contributor

@zeenix zeenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking my promise again by finding more nitpicks. 😆 Sorry! If you don't have the time and motivation anymore, just let me know and I can help out with remaining stuff.

signals.sort_by(|a, b| a.name().partial_cmp(&b.name()).unwrap());

// collect signal method names for collision detection with implicit property change
// receivers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing . again. Sorry! I just like consistency too much. Although in these files I've allowed changes from contributors that missed . but it's inconsistent with rest of the code and even code here, so let's not add to that. 🙏 I'll add . to existing comments/docs in these files myself later.

format!(" #[zbus(property, name = \"{}\")]", p.name())

let prop_change_receiver_name = format!("{name}_changed");
let signal_collision = changed_suffix_signals.get(&prop_change_receiver_name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the previous naming better. The variable isn't holding a collision but rather the Signal. The name makes it sound like it's a boolean so makes code slightly harder to follow/read.

>;

/// State property
// Note: change signal is shadowed by `StateChanged` signal.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • change signal -> changed signal.
  • I just realized btw: wouldn't it be better if this was instead:
Suggested change
// Note: change signal is shadowed by `StateChanged` signal.
// Note: change signal is shadowed by `state_changed` signal method.

? That would also make the xmlgen part simpler and you can also go back to HashSet but this time w/o the caveat of reallocation. 😉

@@ -185,6 +186,11 @@ impl GenTrait<'_> {

let mut signals = iface.signals().to_vec();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, can't we just switch to be a HashMap instead? Wouldn't it make the code even simpler? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants