diff options
author | Sid Nayyar <sidnayyar@google.com> | 2024-04-04 17:12:50 +0100 |
---|---|---|
committer | Giuliano Procida <gprocida@google.com> | 2024-04-25 22:05:48 +0100 |
commit | 577d950c95ddc21398c7b98373821232f5f931f7 (patch) | |
tree | 6904e15c5b4b4f3aee9f7cc7d913d26d99217131 | |
parent | b725c74175b8f000e8f424c764271f0354e51209 (diff) | |
download | stg-577d950c95ddc21398c7b98373821232f5f931f7.tar.gz |
rust: add info test for member functions in Rust enums
PiperOrigin-RevId: 621878723
Change-Id: I48f439a4cb2f4d00c3dd27d0eff20d40f581b5ae
-rw-r--r-- | test_cases/info_tests/enum/expected/methods_rs.elf_stg | 53 | ||||
-rw-r--r-- | test_cases/info_tests/enum/methods.rs | 14 |
2 files changed, 67 insertions, 0 deletions
diff --git a/test_cases/info_tests/enum/expected/methods_rs.elf_stg b/test_cases/info_tests/enum/expected/methods_rs.elf_stg new file mode 100644 index 0000000..855c592 --- /dev/null +++ b/test_cases/info_tests/enum/expected/methods_rs.elf_stg @@ -0,0 +1,53 @@ +version: 0x00000002 +root_id: 0x84ea5130 # interface +primitive { + id: 0x2d2f93e0 + name: "u8" + encoding: UNSIGNED_INTEGER + bytesize: 0x00000001 +} +primitive { + id: 0xd4bacb77 + name: "u32" + encoding: UNSIGNED_INTEGER + bytesize: 0x00000004 +} +enumeration { + id: 0x96f0eeaf + name: "methods::Foo" + definition { + underlying_type_id: 0x2d2f93e0 # u8 + enumerator { + name: "Zero" + } + enumerator { + name: "One" + value: 1 + } + enumerator { + name: "Two" + value: 2 + } + enumerator { + name: "Three" + value: 3 + } + } +} +function { + id: 0x8d8230ce + return_type_id: 0xd4bacb77 # u32 + parameter_id: 0x96f0eeaf # enum methods::Foo +} +elf_symbol { + id: 0x14be2940 + name: "Foo__to_u32" + is_defined: true + symbol_type: FUNCTION + type_id: 0x8d8230ce # u32(enum methods::Foo) + full_name: "methods::to_u32" +} +interface { + id: 0x84ea5130 + symbol_id: 0x14be2940 # u32 methods::to_u32(enum methods::Foo) +} diff --git a/test_cases/info_tests/enum/methods.rs b/test_cases/info_tests/enum/methods.rs new file mode 100644 index 0000000..6f6ff89 --- /dev/null +++ b/test_cases/info_tests/enum/methods.rs @@ -0,0 +1,14 @@ +pub enum Foo { + Zero = 0, + One, + Two, + Three, +} + +impl Foo { + // avoid issues with hash in mangled name + #[export_name = "Foo__to_u32"] + pub fn to_u32(self) -> u32 { + self as u32 + } +} |