Skip to content

Disjoint array handling issue with Microchip SAM L21 #713

@RavuAlHemio

Description

@RavuAlHemio

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 874f7df. Is this a regression in svd2rust or an error in the SVD file?

Thanks in advance!

Activity

burrbull

burrbull commented on Mar 4, 2023

@burrbull
Member

Looks like regression. Thank you for reporting.

cc @n8tlarsen

n8tlarsen

n8tlarsen commented on Mar 6, 2023

@n8tlarsen
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @RavuAlHemio@burrbull@n8tlarsen

        Issue actions

          Disjoint array handling issue with Microchip SAM L21 · Issue #713 · rust-embedded/svd2rust