From b40df6a7bb9b93905b0d27243c1acd3b5f8aa02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Sat, 24 Feb 2024 12:20:28 +0100 Subject: [PATCH] Oops --- cargo-espflash/src/error.rs | 5 ----- espflash/Cargo.toml | 4 ++-- espflash/src/error.rs | 15 +++++++-------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/cargo-espflash/src/error.rs b/cargo-espflash/src/error.rs index 2e3eb2de..2bcb645d 100644 --- a/cargo-espflash/src/error.rs +++ b/cargo-espflash/src/error.rs @@ -60,28 +60,24 @@ pub enum Error { } /// TOML deserialization error -#[cfg(feature = "cli")] #[derive(Debug)] pub struct TomlError { err: toml::de::Error, source: String, } -#[cfg(feature = "cli")] impl TomlError { pub fn new(err: toml::de::Error, source: String) -> Self { Self { err, source } } } -#[cfg(feature = "cli")] impl Display for TomlError { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { write!(f, "Failed to parse toml") } } -#[cfg(feature = "cli")] impl Diagnostic for TomlError { fn source_code(&self) -> Option<&dyn SourceCode> { Some(&self.source) @@ -96,7 +92,6 @@ impl Diagnostic for TomlError { } // NOTE: no `source` on purpose to prevent duplicating the message -#[cfg(feature = "cli")] impl std::error::Error for TomlError {} /// Unsupported target error diff --git a/espflash/Cargo.toml b/espflash/Cargo.toml index 35a168fc..792dfcc0 100644 --- a/espflash/Cargo.toml +++ b/espflash/Cargo.toml @@ -51,7 +51,7 @@ serde = { version = "1.0.196", features = ["derive"] } serialport = { version = "4.3.0", optional = true } sha2 = "0.10.8" slip-codec = { version = "0.4.0", optional = true } -strum = { version = "0.26.1", features = ["derive"], optional = true } +strum = { version = "0.26.1", features = ["derive"] } thiserror = "1.0.56" toml = { version = "0.8.10", optional = true } update-informer = { version = "1.1.0", optional = true } @@ -84,7 +84,7 @@ cli = [ ] # enables connecting to a device via serial port -serialport = ["flashing", "dep:serialport", "dep:slip-codec", "dep:regex", "dep:strum"] +serialport = ["flashing", "dep:serialport", "dep:slip-codec", "dep:regex"] # enables flash stubs and stub commands flashing = ["xmas-elf", "dep:toml"] diff --git a/espflash/src/error.rs b/espflash/src/error.rs index 151facfe..c8d4cff9 100644 --- a/espflash/src/error.rs +++ b/espflash/src/error.rs @@ -8,8 +8,7 @@ use std::{ use miette::Diagnostic; #[cfg(feature = "serialport")] use slip_codec::SlipError; -#[cfg(feature = "serialpot")] -use strum::FromRepr; +use strum::VariantNames; use thiserror::Error; #[cfg(feature = "cli")] @@ -185,7 +184,7 @@ pub enum Error { InvalidElf(#[from] ElfError), #[error("The bootloader returned an error")] - #[cfg(feature = "serialpot")] + #[cfg(feature = "serialport")] #[diagnostic(transparent)] RomError(#[from] RomError), @@ -350,10 +349,10 @@ impl From for TimedOutCommand { } /// Errors originating from a device's ROM functionality -#[derive(Clone, Copy, Debug, Default, Diagnostic, Error, FromRepr)] +#[derive(Clone, Copy, Debug, Default, Diagnostic, Error, strum::FromRepr)] #[non_exhaustive] #[repr(u8)] -#[cfg(feature = "serialpot")] +#[cfg(feature = "serialport")] pub enum RomErrorKind { #[error("Invalid message received")] #[diagnostic(code(espflash::rom::invalid_message))] @@ -429,7 +428,7 @@ pub enum RomErrorKind { Other = 0xff, } -#[cfg(feature = "serialpot")] +#[cfg(feature = "serialport")] impl From for RomErrorKind { fn from(raw: u8) -> Self { Self::from_repr(raw).unwrap_or_default() @@ -439,7 +438,7 @@ impl From for RomErrorKind { /// An error originating from a device's ROM functionality #[derive(Clone, Copy, Debug, Diagnostic, Error)] #[error("Error while running {command} command")] -#[cfg(feature = "serialpot")] +#[cfg(feature = "serialport")] #[non_exhaustive] pub struct RomError { command: CommandType, @@ -447,7 +446,7 @@ pub struct RomError { kind: RomErrorKind, } -#[cfg(feature = "serialpot")] +#[cfg(feature = "serialport")] impl RomError { pub fn new(command: CommandType, kind: RomErrorKind) -> RomError { RomError { command, kind }