Skip to content

Commit d573a04

Browse files
committed
Oops
1 parent 4acf46d commit d573a04

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

cargo-espflash/src/error.rs

-5
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,24 @@ pub enum Error {
6060
}
6161

6262
/// TOML deserialization error
63-
#[cfg(feature = "cli")]
6463
#[derive(Debug)]
6564
pub struct TomlError {
6665
err: toml::de::Error,
6766
source: String,
6867
}
6968

70-
#[cfg(feature = "cli")]
7169
impl TomlError {
7270
pub fn new(err: toml::de::Error, source: String) -> Self {
7371
Self { err, source }
7472
}
7573
}
7674

77-
#[cfg(feature = "cli")]
7875
impl Display for TomlError {
7976
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
8077
write!(f, "Failed to parse toml")
8178
}
8279
}
8380

84-
#[cfg(feature = "cli")]
8581
impl Diagnostic for TomlError {
8682
fn source_code(&self) -> Option<&dyn SourceCode> {
8783
Some(&self.source)
@@ -96,7 +92,6 @@ impl Diagnostic for TomlError {
9692
}
9793

9894
// NOTE: no `source` on purpose to prevent duplicating the message
99-
#[cfg(feature = "cli")]
10095
impl std::error::Error for TomlError {}
10196

10297
/// Unsupported target error

espflash/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ serde = { version = "1.0.196", features = ["derive"] }
5151
serialport = { version = "4.3.0", optional = true }
5252
sha2 = "0.10.8"
5353
slip-codec = { version = "0.4.0", optional = true }
54-
strum = { version = "0.26.1", features = ["derive"], optional = true }
54+
strum = { version = "0.26.1", features = ["derive"] }
5555
thiserror = "1.0.56"
5656
toml = { version = "0.8.10", optional = true }
5757
update-informer = { version = "1.1.0", optional = true }
@@ -84,7 +84,7 @@ cli = [
8484
]
8585

8686
# enables connecting to a device via serial port
87-
serialport = ["flashing", "dep:serialport", "dep:slip-codec", "dep:regex", "dep:strum"]
87+
serialport = ["flashing", "dep:serialport", "dep:slip-codec", "dep:regex"]
8888

8989
# enables flash stubs and stub commands
9090
flashing = ["xmas-elf", "dep:toml"]

espflash/src/error.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use std::{
88
use miette::Diagnostic;
99
#[cfg(feature = "serialport")]
1010
use slip_codec::SlipError;
11-
#[cfg(feature = "serialpot")]
12-
use strum::FromRepr;
11+
use strum::VariantNames;
1312
use thiserror::Error;
1413

1514
#[cfg(feature = "cli")]
@@ -185,7 +184,7 @@ pub enum Error {
185184
InvalidElf(#[from] ElfError),
186185

187186
#[error("The bootloader returned an error")]
188-
#[cfg(feature = "serialpot")]
187+
#[cfg(feature = "serialport")]
189188
#[diagnostic(transparent)]
190189
RomError(#[from] RomError),
191190

@@ -350,10 +349,10 @@ impl From<CommandType> for TimedOutCommand {
350349
}
351350

352351
/// Errors originating from a device's ROM functionality
353-
#[derive(Clone, Copy, Debug, Default, Diagnostic, Error, FromRepr)]
352+
#[derive(Clone, Copy, Debug, Default, Diagnostic, Error, strum::FromRepr)]
354353
#[non_exhaustive]
355354
#[repr(u8)]
356-
#[cfg(feature = "serialpot")]
355+
#[cfg(feature = "serialport")]
357356
pub enum RomErrorKind {
358357
#[error("Invalid message received")]
359358
#[diagnostic(code(espflash::rom::invalid_message))]
@@ -429,7 +428,7 @@ pub enum RomErrorKind {
429428
Other = 0xff,
430429
}
431430

432-
#[cfg(feature = "serialpot")]
431+
#[cfg(feature = "serialport")]
433432
impl From<u8> for RomErrorKind {
434433
fn from(raw: u8) -> Self {
435434
Self::from_repr(raw).unwrap_or_default()
@@ -439,15 +438,15 @@ impl From<u8> for RomErrorKind {
439438
/// An error originating from a device's ROM functionality
440439
#[derive(Clone, Copy, Debug, Diagnostic, Error)]
441440
#[error("Error while running {command} command")]
442-
#[cfg(feature = "serialpot")]
441+
#[cfg(feature = "serialport")]
443442
#[non_exhaustive]
444443
pub struct RomError {
445444
command: CommandType,
446445
#[source]
447446
kind: RomErrorKind,
448447
}
449448

450-
#[cfg(feature = "serialpot")]
449+
#[cfg(feature = "serialport")]
451450
impl RomError {
452451
pub fn new(command: CommandType, kind: RomErrorKind) -> RomError {
453452
RomError { command, kind }

0 commit comments

Comments
 (0)