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

qualify path to Result type in the derive macro quotes #122

Merged
merged 1 commit into from
May 6, 2024

Conversation

iitalics
Copy link
Contributor

@iitalics iitalics commented May 3, 2024

Unqualified references to Result can cause problems when the user shadows the Result type in their own crate.

For example:

type Result<T> = std::result::Result<T, rustbus::connection::Error>;

#[derive(Debug, Clone, rustbus::Signature, rustbus::Unmarshal)]
struct SystemdUnitDescription {
    name: String,
    description: String,
    load_state: String,
    active_state: String,
    sub_state: String,
    followed: String,
    path: ObjectPath<String>,
    job_id: u32,
    job_type: String,
    job_path: ObjectPath<String>,
}
error[E0107]: type alias takes 1 generic argument but 2 generic arguments were supplied
  --> src/systemd.rs:97:44
   |
97 | #[derive(Debug, Clone, rustbus::Signature, rustbus::Unmarshal)]
   |                                            ^^^^^^^^^^^^^^^^^^
   |                                            |
   |                                            expected 1 generic argument
   |                                            help: remove this generic argument
   |
note: type alias defined here, with 1 generic parameter: `T`
  --> src/systemd.rs:95:6
   |
95 | type Result<T> = std::result::Result<T, rustbus::connection::Error>;
   |      ^^^^^^ -
   = note: this error originates in the derive macro `rustbus::Unmarshal` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0107`.
error: could not compile `dbus-experiments` (bin "dbus-experiments") due to previous error

@KillingSpark
Copy link
Owner

Oh damn, thanks! Macros sure have a lot of footguns.

@KillingSpark KillingSpark merged commit bfebd82 into KillingSpark:master May 6, 2024
4 checks passed
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