-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle constants of nested transparent types
- Loading branch information
Showing
5 changed files
with
82 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,32 @@ | ||
#[repr(transparent)] | ||
struct Transparent { field: u8 } | ||
struct TransparentStruct { field: u8 } | ||
|
||
pub const FOO: Transparent = Transparent { field: 0 }; | ||
impl TransparentStruct { | ||
pub const ASSOC_STRUCT_FOO: i64 = 1; | ||
pub const ASSOC_STRUCT_BAR: TransparentStruct = TransparentStruct { field: 2 }; | ||
|
||
// TODO: Only C++ supports template constants so far. | ||
pub const ASSOC_STRUCT_BAZ: Wrapper<TransparentStruct> = Wrapper { field: TransparentStruct { field: 3 } }; | ||
} | ||
|
||
#[repr(transparent)] | ||
struct TransparentTupleStruct(u8); | ||
|
||
#[repr(transparent)] | ||
struct Wrapper<T> { field: T } | ||
|
||
pub const STRUCT_FOO: TransparentStruct = TransparentStruct { field: 4 }; | ||
pub const STRUCT_BAR: TransparentTupleStruct = TransparentTupleStruct(5); | ||
|
||
// TODO: Only C++ supports template constants so far. | ||
pub const STRUCT_BAZ: Wrapper<TransparentStruct> = Wrapper { field: TransparentStruct { field: 6 } }; | ||
|
||
#[repr(transparent)] | ||
struct TransparentStructWithErasedField<T> { | ||
field: Wrapper<T>, | ||
} | ||
|
||
// TODO: Only C++ supports template constants so far. | ||
pub const COMPLEX: TransparentStructWithErasedField<TransparentStruct> = TransparentStructWithErasedField { | ||
field: Wrapper { field: TransparentStruct { field: 7 } } | ||
}; |