Skip to content

Commit 7f9a20b

Browse files
authored
Merge pull request #1068 from felinira/properties-specificity
glib-macros: Specify quoted types explicitly
2 parents 3e6519c + e79910c commit 7f9a20b

File tree

11 files changed

+49
-49
lines changed

11 files changed

+49
-49
lines changed

glib-macros/src/boxed_derive.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::utils::{crate_ident_new, find_attribute_meta, find_nested_meta, parse
99
fn gen_option_to_ptr() -> TokenStream {
1010
quote! {
1111
match s {
12-
Some(s) => ::std::boxed::Box::into_raw(::std::boxed::Box::new(s.clone())),
13-
None => ::std::ptr::null_mut(),
12+
::core::option::Option::Some(s) => ::std::boxed::Box::into_raw(::std::boxed::Box::new(s.clone())),
13+
::core::option::Option::None => ::std::ptr::null_mut(),
1414
};
1515
}
1616
}
@@ -122,7 +122,7 @@ pub fn impl_boxed(input: &syn::DeriveInput) -> TokenStream {
122122

123123
quote! {
124124
impl #crate_ident::subclass::boxed::BoxedType for #name {
125-
const NAME: &'static str = #gtype_name;
125+
const NAME: &'static ::core::primitive::str = #gtype_name;
126126
}
127127

128128
impl #crate_ident::StaticType for #name {
@@ -247,7 +247,7 @@ pub fn impl_boxed(input: &syn::DeriveInput) -> TokenStream {
247247
impl #crate_ident::HasParamSpec for #name {
248248
type ParamSpec = #crate_ident::ParamSpecBoxed;
249249
type SetValue = Self;
250-
type BuilderFn = fn(&str) -> #crate_ident::ParamSpecBoxedBuilder<Self>;
250+
type BuilderFn = fn(&::core::primitive::str) -> #crate_ident::ParamSpecBoxedBuilder<Self>;
251251

252252
fn param_spec_builder() -> Self::BuilderFn {
253253
|name| Self::ParamSpec::builder(name)

glib-macros/src/downgrade_derive/enums.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn derive_downgrade_for_enum(
130130
type Strong = #ident #generics;
131131

132132
fn upgrade(&self) -> ::core::option::Option<Self::Strong> {
133-
Some(match self {#(
133+
::core::option::Option::Some(match self {#(
134134
#upgrade_variants
135135
),*})
136136
}

glib-macros/src/downgrade_derive/structs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub fn derive_downgrade_for_struct(
114114

115115
fn upgrade(&self) -> ::core::option::Option<Self::Strong> {
116116
let Self #destruct = self;
117-
Some(#ident #upgrade)
117+
::core::option::Option::Some(#ident #upgrade)
118118
}
119119
}
120120
};

glib-macros/src/enum_derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub fn impl_enum(input: &syn::DeriveInput) -> TokenStream {
193193
impl #crate_ident::HasParamSpec for #name {
194194
type ParamSpec = #crate_ident::ParamSpecEnum;
195195
type SetValue = Self;
196-
type BuilderFn = fn(&str, Self) -> #crate_ident::ParamSpecEnumBuilder<Self>;
196+
type BuilderFn = fn(&::core::primitive::str, Self) -> #crate_ident::ParamSpecEnumBuilder<Self>;
197197

198198
fn param_spec_builder() -> Self::BuilderFn {
199199
|name, default_value| Self::ParamSpec::builder_with_default(name, default_value)

glib-macros/src/error_domain_derive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn impl_error_domain(input: &syn::DeriveInput) -> TokenStream {
3535

3636
static QUARK: #crate_ident::once_cell::sync::Lazy<#crate_ident::Quark> =
3737
#crate_ident::once_cell::sync::Lazy::new(|| unsafe {
38-
from_glib(#crate_ident::ffi::g_quark_from_static_string(concat!(#domain_name, "\0") as *const str as *const _))
38+
from_glib(#crate_ident::ffi::g_quark_from_static_string(concat!(#domain_name, "\0") as *const ::core::primitive::str as *const _))
3939
});
4040
*QUARK
4141
}
@@ -48,7 +48,7 @@ pub fn impl_error_domain(input: &syn::DeriveInput) -> TokenStream {
4848
#[inline]
4949
fn from(value: i32) -> ::core::option::Option<Self>
5050
where
51-
Self: Sized
51+
Self: ::std::marker::Sized
5252
{
5353
#from_glib
5454
}

glib-macros/src/flags_attribute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub fn impl_flags(attrs: &NestedMeta, input: &DeriveInput) -> TokenStream {
182182
impl #crate_ident::HasParamSpec for #name {
183183
type ParamSpec = #crate_ident::ParamSpecFlags;
184184
type SetValue = Self;
185-
type BuilderFn = fn(&str) -> #crate_ident::ParamSpecFlagsBuilder<Self>;
185+
type BuilderFn = fn(&::core::primitive::str) -> #crate_ident::ParamSpecFlagsBuilder<Self>;
186186

187187
fn param_spec_builder() -> Self::BuilderFn {
188188
|name| Self::ParamSpec::builder(name)

glib-macros/src/properties.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ fn expand_wrapper_getset_properties(props: &[PropDesc]) -> TokenStream2 {
525525
let ident = format_ident!("set_{}", ident);
526526
let target_ty = quote!(<<#ty as #crate_ident::Property>::Value as #crate_ident::HasParamSpec>::SetValue);
527527
let set_ty = if p.nullable {
528-
quote!(Option<impl std::borrow::Borrow<#target_ty>>)
528+
quote!(::core::option::Option<impl std::borrow::Borrow<#target_ty>>)
529529
} else {
530530
quote!(impl std::borrow::Borrow<#target_ty>)
531531
};
@@ -558,7 +558,7 @@ fn expand_wrapper_connect_prop_notify(props: &[PropDesc]) -> TokenStream2 {
558558
let fn_ident = format_ident!("connect_{}_notify", name_to_ident(name));
559559
let span = p.attrs_span;
560560
quote_spanned!(span=> pub fn #fn_ident<F: Fn(&Self) + 'static>(&self, f: F) -> #crate_ident::SignalHandlerId {
561-
self.connect_notify_local(Some(#name), move |this, _| {
561+
self.connect_notify_local(::core::option::Option::Some(#name), move |this, _| {
562562
f(this)
563563
})
564564
})
@@ -619,10 +619,10 @@ fn expand_properties_enum(props: &[PropDesc]) -> TokenStream2 {
619619
impl std::convert::TryFrom<usize> for DerivedPropertiesEnum {
620620
type Error = usize;
621621

622-
fn try_from(item: usize) -> Result<Self, Self::Error> {
622+
fn try_from(item: usize) -> ::core::result::Result<Self, Self::Error> {
623623
match item {
624-
#(#indices => Ok(Self::#properties),)*
625-
_ => Err(item)
624+
#(#indices => ::core::result::Result::Ok(Self::#properties),)*
625+
_ => ::core::result::Result::Err(item)
626626
}
627627
}
628628
}

glib-macros/src/shared_boxed_derive.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn gen_impl_to_value_optional(name: &Ident, crate_ident: &TokenStream) -> TokenS
1616
let mut value = #crate_ident::Value::for_value_type::<Self>();
1717
unsafe {
1818
let ptr = match s {
19-
Some(s) => #refcounted_type_prefix::into_raw(s.0.clone()),
20-
None => ::std::ptr::null(),
19+
::core::option::Option::Some(s) => #refcounted_type_prefix::into_raw(s.0.clone()),
20+
::core::option::Option::None => ::std::ptr::null(),
2121
};
2222

2323
#crate_ident::gobject_ffi::g_value_take_boxed(
@@ -133,7 +133,7 @@ pub fn impl_shared_boxed(input: &syn::DeriveInput) -> proc_macro2::TokenStream {
133133

134134
quote! {
135135
impl #crate_ident::subclass::shared::SharedType for #name {
136-
const NAME: &'static str = #gtype_name;
136+
const NAME: &'static ::core::primitive::str = #gtype_name;
137137

138138
type RefCountedType = #refcounted_type;
139139

@@ -278,7 +278,7 @@ pub fn impl_shared_boxed(input: &syn::DeriveInput) -> proc_macro2::TokenStream {
278278
impl #crate_ident::HasParamSpec for #name {
279279
type ParamSpec = #crate_ident::ParamSpecBoxed;
280280
type SetValue = Self;
281-
type BuilderFn = fn(&str) -> #crate_ident::ParamSpecBoxedBuilder<Self>;
281+
type BuilderFn = fn(&::core::primitive::str) -> #crate_ident::ParamSpecBoxedBuilder<Self>;
282282

283283
fn param_spec_builder() -> Self::BuilderFn {
284284
|name| Self::ParamSpec::builder(name)

glib-macros/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ pub fn gen_enum_from_glib(
153153
let name = &v.ident;
154154
quote_spanned! { v.span() =>
155155
if value == #enum_name::#name as i32 {
156-
return Some(#enum_name::#name);
156+
return ::core::option::Option::Some(#enum_name::#name);
157157
}
158158
}
159159
});
160160
quote! {
161161
#(#recurse)*
162-
None
162+
::core::option::Option::None
163163
}
164164
}

glib-macros/src/value_delegate_derive.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ pub fn impl_value_delegate(input: ValueDelegateInput) -> syn::Result<proc_macro:
132132
let to_value_optional = nullable.then(|| {
133133
quote! {
134134
impl #crate_ident::value::ToValueOptional for #ident {
135-
fn to_value_optional(s: Option<&Self>) -> #crate_ident::value::Value {
136-
if let Some(this) = s {
137-
#crate_ident::value::ToValue::to_value(&Some(&#delegate_value))
135+
fn to_value_optional(s: ::core::option::Option<&Self>) -> #crate_ident::value::Value {
136+
if let ::core::option::Option::Some(this) = s {
137+
#crate_ident::value::ToValue::to_value(&::core::option::Option::Some(&#delegate_value))
138138
} else {
139-
#crate_ident::value::ToValueOptional::to_value_optional(None::<&#delegated_ty>)
139+
#crate_ident::value::ToValueOptional::to_value_optional(::core::option::Option::None::<&#delegated_ty>)
140140
}
141141
}
142142
}

glib-macros/src/variant_derive.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ fn derive_variant_for_struct(
9999
impl #impl_generics #glib::FromVariant for #ident #type_generics #where_clause {
100100
fn from_variant(variant: &#glib::Variant) -> ::core::option::Option<Self> {
101101
if !variant.is_container() {
102-
return None;
102+
return ::core::option::Option::None;
103103
}
104-
Some(Self(
104+
::core::option::Option::Some(Self(
105105
#(
106106
match variant.try_child_get::<#types>(#idents) {
107-
Ok(Some(field)) => field,
108-
_ => return None,
107+
::core::result::Result::Ok(::core::option::Option::Some(field)) => field,
108+
_ => return ::core::option::Option::None,
109109
}
110110
),*
111111
))
@@ -182,13 +182,13 @@ fn derive_variant_for_struct(
182182
impl #impl_generics #glib::FromVariant for #ident #type_generics #where_clause {
183183
fn from_variant(variant: &#glib::Variant) -> ::core::option::Option<Self> {
184184
if !variant.is_container() {
185-
return None;
185+
return ::core::option::Option::None;
186186
}
187-
Some(Self {
187+
::core::option::Option::Some(Self {
188188
#(
189189
#idents: match variant.try_child_get::<#types>(#counts) {
190-
Ok(Some(field)) => field,
191-
_ => return None,
190+
::core::result::Result::Ok(::core::option::Option::Some(field)) => field,
191+
_ => return ::core::option::Option::None,
192192
}
193193
),*
194194
})
@@ -227,7 +227,7 @@ fn derive_variant_for_struct(
227227
let from_variant = quote! {
228228
impl #impl_generics #glib::FromVariant for #ident #type_generics #where_clause {
229229
fn from_variant(variant: &#glib::Variant) -> ::core::option::Option<Self> {
230-
Some(Self)
230+
::core::option::Option::Some(Self)
231231
}
232232
}
233233
};
@@ -421,13 +421,13 @@ fn derive_variant_for_enum(
421421
)?
422422
}
423423
});
424-
quote! { #tag => ::std::option::Option::Some(Self::#ident { #(#fields),* }), }
424+
quote! { #tag => ::core::option::Option::Some(Self::#ident { #(#fields),* }), }
425425
}
426426
syn::Fields::Unnamed(FieldsUnnamed { unnamed, .. }) => {
427427
let indices = 0..unnamed.iter().count();
428428
let repr = unnamed.iter().map(|f| &f.ty);
429429
quote! {
430-
#tag => ::std::option::Option::Some(Self::#ident(
430+
#tag => ::core::option::Option::Some(Self::#ident(
431431
#(
432432
<#repr as #glib::FromVariant>::from_variant(
433433
&#glib::Variant::try_child_value(&value, #indices)?
@@ -437,7 +437,7 @@ fn derive_variant_for_enum(
437437
}
438438
}
439439
syn::Fields::Unit => {
440-
quote! { #tag => ::std::option::Option::Some(Self::#ident), }
440+
quote! { #tag => ::core::option::Option::Some(Self::#ident), }
441441
}
442442
}
443443
});
@@ -477,14 +477,14 @@ fn derive_variant_for_enum(
477477
}
478478

479479
impl #impl_generics #glib::FromVariant for #ident #type_generics #where_clause {
480-
fn from_variant(variant: &#glib::Variant) -> ::std::option::Option<Self> {
480+
fn from_variant(variant: &#glib::Variant) -> ::core::option::Option<Self> {
481481
let (tag, value) = <(#repr, #glib::Variant) as #glib::FromVariant>::from_variant(&variant)?;
482482
if !#glib::VariantTy::is_tuple(#glib::Variant::type_(&value)) {
483-
return ::std::option::Option::None;
483+
return ::core::option::Option::None;
484484
}
485485
match #tag_match {
486486
#(#from)*
487-
_ => ::std::option::Option::None
487+
_ => ::core::option::Option::None
488488
}
489489
}
490490
}
@@ -520,8 +520,8 @@ fn derive_variant_for_c_enum(
520520
quote! {
521521
let tag = #glib::Variant::str(&variant)?;
522522
match tag {
523-
#(#nicks2 => ::std::option::Option::Some(Self::#idents2),)*
524-
_ => ::std::option::Option::None
523+
#(#nicks2 => ::core::option::Option::Some(Self::#idents2),)*
524+
_ => ::core::option::Option::None
525525
}
526526
},
527527
)
@@ -535,9 +535,9 @@ fn derive_variant_for_c_enum(
535535
quote! {
536536
let value = <#repr as #glib::FromVariant>::from_variant(&variant)?;
537537
#(if value == Self::#idents as #repr {
538-
return Some(Self::#idents);
538+
return ::core::option::Option::Some(Self::#idents);
539539
})*
540-
None
540+
::core::option::Option::None
541541
},
542542
)
543543
}
@@ -554,10 +554,10 @@ fn derive_variant_for_c_enum(
554554
quote! {
555555
let ty = <Self as #glib::StaticType>::static_type();
556556
let enum_class = #glib::EnumClass::new(ty);
557-
let enum_class = ::std::option::Option::unwrap(enum_class);
557+
let enum_class = ::core::option::Option::unwrap(enum_class);
558558
let value = <Self as #glib::translate::IntoGlib>::into_glib(*self);
559559
let value = #glib::EnumClass::value(&enum_class, value);
560-
let value = ::std::option::Option::unwrap(value);
560+
let value = ::core::option::Option::unwrap(value);
561561
let nick = #glib::EnumValue::nick(&value);
562562
#glib::ToVariant::to_variant(nick)
563563
},
@@ -583,7 +583,7 @@ fn derive_variant_for_c_enum(
583583
quote! {
584584
let ty = <Self as #glib::StaticType>::static_type();
585585
let flags_class = #glib::FlagsClass::new(ty);
586-
let flags_class = ::std::option::Option::unwrap(flags_class);
586+
let flags_class = ::core::option::Option::unwrap(flags_class);
587587
let value = <Self as #glib::translate::IntoGlib>::into_glib(*self);
588588
let s = #glib::FlagsClass::to_nick_string(&flags_class, value);
589589
#glib::ToVariant::to_variant(&s)
@@ -593,7 +593,7 @@ fn derive_variant_for_c_enum(
593593
let flags_class = #glib::FlagsClass::new(ty)?;
594594
let s = #glib::Variant::str(&variant)?;
595595
let value = #glib::FlagsClass::from_nick_string(&flags_class, s).ok()?;
596-
Some(unsafe { #glib::translate::from_glib(value) })
596+
::core::option::Option::Some(unsafe { #glib::translate::from_glib(value) })
597597
},
598598
),
599599
};
@@ -624,7 +624,7 @@ fn derive_variant_for_c_enum(
624624
}
625625

626626
impl #impl_generics #glib::FromVariant for #ident #type_generics #where_clause {
627-
fn from_variant(variant: &#glib::Variant) -> ::std::option::Option<Self> {
627+
fn from_variant(variant: &#glib::Variant) -> ::core::option::Option<Self> {
628628
#from_variant
629629
}
630630
}

0 commit comments

Comments
 (0)