mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Bulk gcore
cleanup, replace core
and alloc
with std
(#2735)
* gcore: replace `core` and `alloc` paths with `std` * node-graph: remove unnecessary path prefix * gcore: remove most `#[cfg(target_arch = "spirv")]`, keep some potentially useful ones --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
301368a0df
commit
990d5b37cf
46 changed files with 287 additions and 313 deletions
|
@ -56,7 +56,7 @@ pub(crate) fn generate_node_code(parsed: &ParsedNodeFn) -> syn::Result<TokenStre
|
|||
.zip(field_names.iter())
|
||||
.map(|zipped| match zipped {
|
||||
(Some(name), _) => name.value(),
|
||||
(_, name) => name.to_string().to_case(convert_case::Case::Title),
|
||||
(_, name) => name.to_string().to_case(Case::Title),
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -510,7 +510,7 @@ fn generate_phantom_data<'a>(fn_generics: impl Iterator<Item = &'a crate::Generi
|
|||
(fn_generic_params, phantom_data_declerations)
|
||||
}
|
||||
|
||||
fn generate_register_node_impl(parsed: &ParsedNodeFn, field_names: &[&Ident], struct_name: &Ident, identifier: &TokenStream2) -> Result<TokenStream2, syn::Error> {
|
||||
fn generate_register_node_impl(parsed: &ParsedNodeFn, field_names: &[&Ident], struct_name: &Ident, identifier: &TokenStream2) -> Result<TokenStream2, Error> {
|
||||
if parsed.attributes.skip_impl {
|
||||
return Ok(quote!());
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ struct LifetimeReplacer(&'static str);
|
|||
|
||||
impl VisitMut for LifetimeReplacer {
|
||||
fn visit_lifetime_mut(&mut self, lifetime: &mut Lifetime) {
|
||||
lifetime.ident = syn::Ident::new(self.0, lifetime.ident.span());
|
||||
lifetime.ident = Ident::new(self.0, lifetime.ident.span());
|
||||
}
|
||||
|
||||
fn visit_type_mut(&mut self, ty: &mut Type) {
|
||||
|
@ -662,7 +662,7 @@ struct FilterUsedGenerics {
|
|||
}
|
||||
|
||||
impl VisitMut for FilterUsedGenerics {
|
||||
fn visit_lifetime_mut(&mut self, used_lifetime: &mut syn::Lifetime) {
|
||||
fn visit_lifetime_mut(&mut self, used_lifetime: &mut Lifetime) {
|
||||
for (generic, used) in self.all.iter().zip(self.used.iter_mut()) {
|
||||
let crate::GenericParam::Lifetime(lifetime_param) = generic else { continue };
|
||||
if used_lifetime == &lifetime_param.lifetime {
|
||||
|
|
|
@ -111,12 +111,8 @@ fn derive_enum(enum_attributes: &[Attribute], name: Ident, input: syn::DataEnum)
|
|||
})
|
||||
.collect();
|
||||
|
||||
let crate_name = proc_macro_crate::crate_name("graphene-core").map_err(|e| {
|
||||
syn::Error::new(
|
||||
proc_macro2::Span::call_site(),
|
||||
format!("Failed to find location of graphene_core. Make sure it is imported as a dependency: {}", e),
|
||||
)
|
||||
})?;
|
||||
let crate_name = proc_macro_crate::crate_name("graphene-core")
|
||||
.map_err(|e| syn::Error::new(Span::call_site(), format!("Failed to find location of graphene_core. Make sure it is imported as a dependency: {}", e)))?;
|
||||
let crate_name = match crate_name {
|
||||
proc_macro_crate::FoundCrate::Itself => quote!(crate),
|
||||
proc_macro_crate::FoundCrate::Name(name) => {
|
||||
|
@ -144,19 +140,19 @@ fn derive_enum(enum_attributes: &[Attribute], name: Ident, input: syn::DataEnum)
|
|||
let docstring = match &variant.basic_item.description {
|
||||
Some(s) => {
|
||||
let s = s.trim();
|
||||
quote! { Some(::alloc::borrow::Cow::Borrowed(#s)) }
|
||||
quote! { Some(::std::borrow::Cow::Borrowed(#s)) }
|
||||
}
|
||||
None => quote! { None },
|
||||
};
|
||||
let icon = match &variant.basic_item.icon {
|
||||
Some(s) => quote! { Some(::alloc::borrow::Cow::Borrowed(#s)) },
|
||||
Some(s) => quote! { Some(::std::borrow::Cow::Borrowed(#s)) },
|
||||
None => quote! { None },
|
||||
};
|
||||
quote! {
|
||||
(
|
||||
#name::#vname, #crate_name::registry::VariantMetadata {
|
||||
name: ::alloc::borrow::Cow::Borrowed(#vname_str),
|
||||
label: ::alloc::borrow::Cow::Borrowed(#label),
|
||||
name: ::std::borrow::Cow::Borrowed(#vname_str),
|
||||
label: ::std::borrow::Cow::Borrowed(#label),
|
||||
docstring: #docstring,
|
||||
icon: #icon,
|
||||
}
|
||||
|
|
|
@ -88,10 +88,10 @@ impl Parse for ParsedWidgetOverride {
|
|||
let lit: LitStr = input.parse()?;
|
||||
Ok(ParsedWidgetOverride::Custom(lit))
|
||||
}
|
||||
_ => Err(syn::Error::new(variant.span(), "Unknown ParsedWidgetOverride variant")),
|
||||
_ => Err(Error::new(variant.span(), "Unknown ParsedWidgetOverride variant")),
|
||||
}
|
||||
} else {
|
||||
Err(syn::Error::new(input.span(), "Expected ParsedWidgetOverride::<variant>"))
|
||||
Err(Error::new(input.span(), "Expected ParsedWidgetOverride::<variant>"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1214,7 +1214,7 @@ mod tests {
|
|||
let attr = quote!(category("Test"));
|
||||
|
||||
// Use quote_spanned! to attach a specific span to the problematic part
|
||||
let problem_span = proc_macro2::Span::call_site(); // You could create a custom span here if needed
|
||||
let problem_span = Span::call_site(); // You could create a custom span here if needed
|
||||
let tuples = quote_spanned!(problem_span=> () ());
|
||||
let input = quote! {
|
||||
fn test_node(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue