embassy-rs / embassy-rs/chiptool

RemoveUselessEnums explodes with useless enum that has no `0` variant.

Open
#54 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
65
Forks
54
PR merge metrics
No merged PRs in 30d

Description

From the MSPM0C110x SVD files, with the SYSCTL peripheral, the following enum causes a panic in `!RemoveUselessEnums` with the latest chiptool (57953f5c)

Yes this enum is some internal testing or undefined register which TI left in their SVD files...

```yaml
enum/FLBANK_SWAP:
bit_size: 1
variants:
- name: YES
description: System has a CSC.
value: 1
- name: NO
description: No, system does not have a CSC.
value: 2
```

I suspect the issue is that `YES` has a value of 1 and `NO` has a value of 2, which causes the transform to explode since there is no variant with a value of `0`.

```
thread 'main' panicked at src/transform/delete_useless_enums.rs:76:69:
called `Option::unwrap()` on a `None` value
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic
3: core::option::unwrap_failed
4: chiptool::transform::delete_useless_enums::DeleteUselessEnums::run
5: chiptool::apply_transform
6: chiptool::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.