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:
Firestar99 2025-06-22 01:08:33 +02:00 committed by GitHub
parent 301368a0df
commit 990d5b37cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 287 additions and 313 deletions

View file

@ -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 {

View file

@ -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,
}

View file

@ -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(