From 14823d669f4066d80b4b577a2cf41ec1be5d866e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Mon, 26 Jun 2023 18:44:09 +0200 Subject: [PATCH] Prevent constructing some types --- esp-hal-common/src/dma/gdma.rs | 5 +++++ esp-hal-common/src/dma/pdma.rs | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/esp-hal-common/src/dma/gdma.rs b/esp-hal-common/src/dma/gdma.rs index 211e8733e..e1e7d9785 100644 --- a/esp-hal-common/src/dma/gdma.rs +++ b/esp-hal-common/src/dma/gdma.rs @@ -9,6 +9,7 @@ use crate::{ macro_rules! impl_channel { ($num: literal) => { paste::paste! { + #[non_exhaustive] pub struct [] {} impl RegisterAccess for [] { @@ -365,6 +366,7 @@ macro_rules! impl_channel { } } + #[non_exhaustive] pub struct [] {} impl<'a> TxChannel<[]> for [] { @@ -375,6 +377,7 @@ macro_rules! impl_channel { } } + #[non_exhaustive] pub struct [] {} impl<'a> RxChannel<[]> for [] { @@ -385,6 +388,7 @@ macro_rules! impl_channel { } } + #[non_exhaustive] pub struct [] {} impl [] { @@ -437,6 +441,7 @@ macro_rules! impl_channel { } } + #[non_exhaustive] pub struct [] {} impl PeripheralMarker for [] {} diff --git a/esp-hal-common/src/dma/pdma.rs b/esp-hal-common/src/dma/pdma.rs index 1dcb87a77..f4ddcbc48 100644 --- a/esp-hal-common/src/dma/pdma.rs +++ b/esp-hal-common/src/dma/pdma.rs @@ -9,6 +9,7 @@ use crate::{ macro_rules! ImplSpiChannel { ($num: literal) => { paste::paste! { + #[non_exhaustive] pub struct [] {} impl RegisterAccess for [] { @@ -195,6 +196,7 @@ macro_rules! ImplSpiChannel { } } + #[non_exhaustive] pub struct [] {} impl<'a> TxChannel<[]> for [] { @@ -205,6 +207,7 @@ macro_rules! ImplSpiChannel { } } + #[non_exhaustive] pub struct [] {} impl<'a> RxChannel<[]> for [] { @@ -215,6 +218,7 @@ macro_rules! ImplSpiChannel { } } + #[non_exhaustive] pub struct [] {} impl [] { @@ -511,11 +515,13 @@ macro_rules! ImplI2sChannel { }; } +#[non_exhaustive] pub struct Spi2DmaSuitablePeripheral {} impl PeripheralMarker for Spi2DmaSuitablePeripheral {} impl SpiPeripheral for Spi2DmaSuitablePeripheral {} impl Spi2Peripheral for Spi2DmaSuitablePeripheral {} +#[non_exhaustive] pub struct Spi3DmaSuitablePeripheral {} impl PeripheralMarker for Spi3DmaSuitablePeripheral {} impl SpiPeripheral for Spi3DmaSuitablePeripheral {} @@ -524,6 +530,7 @@ impl Spi3Peripheral for Spi3DmaSuitablePeripheral {} ImplSpiChannel!(2); ImplSpiChannel!(3); +#[non_exhaustive] pub struct I2s0DmaSuitablePeripheral {} impl PeripheralMarker for I2s0DmaSuitablePeripheral {} impl I2sPeripheral for I2s0DmaSuitablePeripheral {} @@ -531,6 +538,7 @@ impl I2s0Peripheral for I2s0DmaSuitablePeripheral {} ImplI2sChannel!(0, "I2S0"); +#[non_exhaustive] pub struct I2s1DmaSuitablePeripheral {} impl PeripheralMarker for I2s1DmaSuitablePeripheral {} impl I2sPeripheral for I2s1DmaSuitablePeripheral {}