Skip to content

Commit

Permalink
rust: ensure all phantomdata properties of newtypes are public
Browse files Browse the repository at this point in the history
  • Loading branch information
timbod7 committed Apr 20, 2023
1 parent b3cd17c commit 55962cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion haskell/compiler/adlc-lib1/ADL/Compiler/Backends/Rust.hs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ genNewType m decl Newtype{n_typeParams=typeParams, n_typeExpr=te} = do
render name typeParams typeExprStr phantomFields
= ctemplate "#[derive($1)]" [T.intercalate "," (S.toList (stdTraitsFor te))]
<> ctemplate "pub struct $1$2($3);"
[name, typeParamsExpr typeParams, T.intercalate ", " (["pub " <> typeExprStr] <> phantomFields)]
[name, typeParamsExpr typeParams, T.intercalate ", " (["pub " <> typeExprStr] <> (map ("pub " <>) phantomFields))]
phantomTypeParams = S.toList (S.difference (S.fromList typeParams) (typeExprTypeParams te))


Expand Down
8 changes: 4 additions & 4 deletions haskell/compiler/tests/test7/rs-output/test7/adl/test7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ pub struct Int3(pub i64);
pub type Int4 = i64;

#[derive(Clone,Deserialize,Eq,Hash,PartialEq,Serialize)]
pub struct Int5<X>(pub i64, PhantomData<X>);
pub struct Int5<X>(pub i64, pub PhantomData<X>);

#[derive(Clone,Deserialize,Eq,Hash,PartialEq,Serialize)]
pub struct Int6<X>(pub i64, PhantomData<X>);
pub struct Int6<X>(pub i64, pub PhantomData<X>);

pub type String1 = String;

Expand All @@ -47,10 +47,10 @@ pub struct String3(pub String);
pub type String4 = String;

#[derive(Clone,Deserialize,Eq,Hash,PartialEq,Serialize)]
pub struct String5<X>(pub String, PhantomData<X>);
pub struct String5<X>(pub String, pub PhantomData<X>);

#[derive(Clone,Deserialize,Eq,Hash,PartialEq,Serialize)]
pub struct String6<X>(pub String, PhantomData<X>);
pub struct String6<X>(pub String, pub PhantomData<X>);

pub type IntPoint1 = Point<i64>;

Expand Down

0 comments on commit 55962cd

Please sign in to comment.