Skip to content

Derive macro panicks on anyType #43

@mtorromeo

Description

@mtorromeo

Hi,
while trying to derive structs from some xsd I experienced a panic in the derive macro with an unhelpful message:

error: proc-macro derive panicked
  --> src/main.rs:16:17
   |
16 | #[derive(Debug, XmlSchema)]
   |                 ^^^^^^^^^
   |
   = help: message: called `Option::unwrap()` on a `None` value

I tracked down the problem in the handling of anyType.

This is the minimal reproducible xsd that I could come up with:

<?xml version="1.0" encoding="UTF-8"?>

<schema xmlns="http://www.w3.org/2001/XMLSchema">

    <complexType name="mixedType">
        <complexContent>
            <restriction base="anyType"></restriction>
        </complexContent>
    </complexType>

</schema>

The panick is triggered by this unwrap: https://github.com/media-io/xml-schema/blob/a6a5b5800403d840e0d76eb6cd195c6854b1928d/xml_schema_derive/src/xsd/complex_content.rs#L19

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions