Skip to content

unsafe attribute used without unsafe #924

@LennyPhoenix

Description

@LennyPhoenix

svd2rust seems to generate code that fails to compile on rustc v1.85.0:

❯ cargo build
   Compiling stm32l476 v0.1.0 (/home/lenny/Source/stm32l476)
error: unsafe attribute used without unsafe
    --> src/lib.rs:1034:3
     |
1034 | #[no_mangle]
     |   ^^^^^^^^^ usage of unsafe attribute
     |
help: wrap the attribute in `unsafe(...)`
     |
1034 | #[unsafe(no_mangle)]
     |   +++++++         +

Manually adding the unsafe wrapper fixes things.

The chunk in question:

#[doc = "Digital camera interface"]
pub mod dcmi;
#[no_mangle]
static mut DEVICE_PERIPHERALS: bool = false;
#[doc = r" All the peripherals."]
#[allow(non_snake_case)]
pub struct Peripherals {
    #[doc = "DAC"]
    pub dac: Dac,
    #[doc = "DMA1"]
    pub dma1: Dma1,
    #[doc = "DMA2"]
    pub dma2: Dma2,
    #[doc = "CRC"]
    pub crc: Crc,
    // ...
}

SVD file used: https://www.st.com/resource/en/svd/stm32l4_svd.zip

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