svd2rust
svd2rust copied to clipboard
Disjoint array handling issue with Microchip SAM L21
Greetings,
I have run into an issue while upgrading my SAM L21 crates. With the SVD file ATSAML21G16B.svd, svd2rust v0.27.2 was successful while v0.28.0 (and current master) lead to the following compilation error:
error[E0412]: cannot find type `PMUX1_0` in this scope
--> src\port.rs:58:19
|
58 | pub pmux1_0: [PMUX1_0; 16],
| ^^^^^^^ help: a type alias with a similar name exists: `PMUX1_`
...
111 | pub type PMUX0_ = crate::Reg<pmux0_::PMUX0__SPEC>;
| -------------------------------------------------- similarly named type alias `PMUX1_` defined here
error[E0412]: cannot find type `PINCFG1_0` in this scope
--> src\port.rs:60:21
|
60 | pub pincfg1_0: [PINCFG1_0; 32],
| ^^^^^^^^^ help: a type alias with a similar name exists: `PINCFG1_`
...
117 | pub type PINCFG0_ = crate::Reg<pincfg0_::PINCFG0__SPEC>;
| -------------------------------------------------------- similarly named type alias `PINCFG1_` defined here
For more information about this error, try `rustc --explain E0412`.
error: could not compile `atsaml21g16b` due to 2 previous errors
In the generated file port.rs, the block:
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
// [...]
#[doc = "0xb0..0xc0 - Peripheral Multiplexing n - Group 1"]
pub pmux1_: [PMUX1_; 16],
#[doc = "0xc0..0xe0 - Pin Configuration n - Group 1"]
pub pincfg1_: [PINCFG1_; 32],
}
has changed to:
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
// [...]
#[doc = "0xb0..0xc0 - Peripheral Multiplexing n - Group 1"]
pub pmux1_0: [PMUX1_0; 16],
#[doc = "0xc0..0xe0 - Pin Configuration n - Group 1"]
pub pincfg1_0: [PINCFG1_0; 32],
}
A git bisect pointed me to 874f7df2b634e7fe85388b6416c1370e84802a3f. Is this a regression in svd2rust or an error in the SVD file?
Thanks in advance!
Looks like regression. Thank you for reporting.
cc @n8tlarsen
Looks like the deriveFrom key may be throwing off the type name resolution when used with arrays. I'll take a look at it more in-depth.