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
}

0 commit comments

Comments
 (0)