You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on patching and fixing up the SVD for the LPC11U1x/2x/3x series of MCUs. One of the modifications I made was to use derivedFrom in more places (so that the types used could also be used everywhere), and another was to add a generic set of IOCON registers. Part of the SVD in question
<field derivedFrom="IOCON.PIO0[%s].MODE">, however, causes svd2rust to panic with pio0%s is not a valid Ident. I attempted to resolve this on master by doing a patch similar to the following
This leads to svd2rust not panicking, though it does produce invalid code for the IOCON RegisterBlock (return type of PIO10 instead of PIO1 for the pio1 method, &PIO10 instead of &PIO1 for pio1_iter). I did a similar patch to case-defaults (#805), and this resulted in what appeared to be correct codegen.
RUST_BACKTRACE=1 panic:
thread 'main' panicked at src/util.rs:95:9:
"pio0%s" is not a valid Ident
stack backtrace:
0: rust_begin_unwind
at /rustc/f688dd684faca5b31b156fac2c6e0ae81fc9bc90/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/f688dd684faca5b31b156fac2c6e0ae81fc9bc90/library/core/src/panicking.rs:72:14
2: proc_macro2::fallback::validate_ident
at /home/masterr3c0rd/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.71/src/fallback.rs:828:9
3: proc_macro2::fallback::Ident::new_checked
at /home/masterr3c0rd/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.71/src/fallback.rs:760:9
4: proc_macro2::imp::Ident::new_checked
at /home/masterr3c0rd/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.71/src/wrapper.rs:646:50
5: proc_macro2::Ident::new
at /home/masterr3c0rd/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.71/src/lib.rs:956:21
6: svd2rust::util::ToSanitizedCase::to_snake_case_ident
at /mnt/projects/Personal/svd2rust/src/util.rs:95:9
7: svd2rust::generate::register::base_syn_path
at /mnt/projects/Personal/svd2rust/src/generate/register.rs:1465:36
8: svd2rust::generate::register::fields
at /mnt/projects/Personal/svd2rust/src/generate/register.rs:883:37
9: svd2rust::generate::register::render_register_mod
at /mnt/projects/Personal/svd2rust/src/generate/register.rs:283:17
10: svd2rust::generate::register::render
at /mnt/projects/Personal/svd2rust/src/generate/register.rs:112:25
11: svd2rust::generate::peripheral::render_ercs
at /mnt/projects/Personal/svd2rust/src/generate/peripheral.rs:1355:36
12: svd2rust::generate::peripheral::render
at /mnt/projects/Personal/svd2rust/src/generate/peripheral.rs:240:21
13: svd2rust::generate::device::render
at /mnt/projects/Personal/svd2rust/src/generate/device.rs:204:22
14: svd2rust::run
at /mnt/projects/Personal/svd2rust/src/main.rs:272:17
15: svd2rust::main
at /mnt/projects/Personal/svd2rust/src/main.rs:363:25
16: core::ops::function::FnOnce::call_once
at /rustc/f688dd684faca5b31b156fac2c6e0ae81fc9bc90/library/core/src/ops/function.rs:250:5
The text was updated successfully, but these errors were encountered:
This produces correct code, although the accessor for IOCON.PIO1[%s] is named pio10, and uses Pio10 as the alias to Pio0 (which is imported correctly, unlike master). Was easily fixed by simply adding dimName to my SVD.
I'm working on patching and fixing up the SVD for the LPC11U1x/2x/3x series of MCUs. One of the modifications I made was to use
derivedFrom
in more places (so that the types used could also be used everywhere), and another was to add a generic set of IOCON registers. Part of the SVD in question<field derivedFrom="IOCON.PIO0[%s].MODE">
, however, causes svd2rust to panic withpio0%s is not a valid Ident
. I attempted to resolve this onmaster
by doing a patch similar to the followingThis leads to
svd2rust
not panicking, though it does produce invalid code for the IOCON RegisterBlock (return type ofPIO10
instead ofPIO1
for thepio1
method,&PIO10
instead of&PIO1
forpio1_iter
). I did a similar patch tocase-defaults
(#805), and this resulted in what appeared to be correct codegen.RUST_BACKTRACE=1
panic:The text was updated successfully, but these errors were encountered: