Skip to content

Commit

Permalink
Do not expand type aliases in rust mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nilehmann committed Jan 2, 2024
1 parent 2ca82a0 commit 4e0ae3a
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions lib/flux-attrs/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1620,13 +1620,9 @@ impl ToTokens for ItemFn {

impl ToTokens for ItemType {
fn to_tokens(&self, tokens: &mut TokenStream) {
let flux_type = ToTokensFlux(self);
let rust_type = ToTokensRust(self);
quote! {
#[flux_tool::alias(#flux_type)]
#rust_type
}
.to_tokens(tokens);
#[cfg(flux_sysroot)]
self.flux_tool_attr().to_tokens(tokens);
self.to_tokens_inner(tokens, Mode::Rust);
}
}

Expand All @@ -1636,12 +1632,6 @@ impl ToTokens for ToTokensFlux<&ItemType> {
}
}

impl ToTokens for ToTokensRust<&ItemType> {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.0.to_tokens_inner(tokens, Mode::Rust);
}
}

impl ToTokens for ToTokensFlux<&Type> {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.0.to_tokens_inner(tokens, Mode::Flux);
Expand All @@ -1666,6 +1656,14 @@ impl ItemType {
self.semi_token.to_tokens(tokens);
}
}

#[cfg(flux_sysroot)]
fn flux_tool_attr(&self) -> TokenStream {
let flux_type = ToTokensFlux(self);
quote! {
#[flux_tool::alias(#flux_type)]
}
}
}

impl Generics {
Expand Down

0 comments on commit 4e0ae3a

Please sign in to comment.