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
2 changes: 0 additions & 2 deletions glib-macros/src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,6 @@ pub fn impl_derive_props(input: PropsMacroInput) -> TokenStream {
};

let expanded = quote! {
use #crate_ident::property::{PropertyGet, PropertySet};
Copy link
Member

Choose a reason for hiding this comment

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

Why was it even importing them if apparently it was not used at all? :)


#properties_enum

impl #crate_ident::subclass::object::DerivedObjectProperties for #struct_ident {
Expand Down
13 changes: 13 additions & 0 deletions glib-macros/tests/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,19 @@ mod foo {
.expect("Setter to be only called once");
}
}

/// Checks that `Properties` does not pollute the scope with
/// trait imports, as it did in older versions.
#[test]
fn no_import_leaks() {
// `vec.get` can match these methods (in order of precedence):
// (1) `<Vec<String> as PropertyGet>::get`
// (2) `<[String]>::get` through deref of `Vec<String>`
// Had the macro introduced `PropertyGet` into the scope, it would
// resolve to (1), which we do not want.
let vec: Vec<String> = vec![String::new(); 2];
assert_eq!(vec.get(1), Some(&String::new()));
}
}

glib::wrapper! {
Expand Down
Loading