Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macro: ensure that cfg attrs are set for type alias verify generation #1464

Merged
merged 1 commit into from
Mar 12, 2025
Merged
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
3 changes: 3 additions & 0 deletions macro/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,7 @@ fn expand_type_alias(alias: &TypeAlias) -> TokenStream {
}

fn expand_type_alias_verify(alias: &TypeAlias, types: &Types) -> TokenStream {
let attrs = &alias.attrs;
let ident = &alias.name.rust;
let type_id = type_id(&alias.name);
let begin_span = alias.type_token.span;
Expand All @@ -1272,12 +1273,14 @@ fn expand_type_alias_verify(alias: &TypeAlias, types: &Types) -> TokenStream {
let end = quote_spanned!(end_span=> >);

let mut verify = quote! {
#attrs
const _: fn() = #begin #ident, #type_id #end;
};

if types.required_trivial.contains_key(&alias.name.rust) {
let begin = quote_spanned!(begin_span=> ::cxx::private::verify_extern_kind::<);
verify.extend(quote! {
#attrs
const _: fn() = #begin #ident, ::cxx::kind::Trivial #end;
});
}
Expand Down
Loading