Skip to content

Commit e0576ce

Browse files
committed
Use core::error::Error instead of std::error::Error
...and let all error types derive from it even in no-std mode.
1 parent d8761c0 commit e0576ce

File tree

10 files changed

+14
-28
lines changed

10 files changed

+14
-28
lines changed

regex-automata/src/dfa/automaton.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,8 +2114,7 @@ impl StartError {
21142114
}
21152115
}
21162116

2117-
#[cfg(feature = "std")]
2118-
impl std::error::Error for StartError {}
2117+
impl core::error::Error for StartError {}
21192118

21202119
impl core::fmt::Display for StartError {
21212120
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {

regex-automata/src/util/primitives.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,7 @@ impl SmallIndexError {
384384
}
385385
}
386386

387-
#[cfg(feature = "std")]
388-
impl std::error::Error for SmallIndexError {}
387+
impl core::error::Error for SmallIndexError {}
389388

390389
impl core::fmt::Display for SmallIndexError {
391390
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
@@ -646,8 +645,7 @@ macro_rules! index_type_impls {
646645
}
647646
}
648647

649-
#[cfg(feature = "std")]
650-
impl std::error::Error for $err {}
648+
impl core::error::Error for $err {}
651649

652650
impl core::fmt::Display for $err {
653651
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {

regex-automata/src/util/search.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,8 +1337,7 @@ pub struct PatternSetInsertError {
13371337
capacity: usize,
13381338
}
13391339

1340-
#[cfg(feature = "std")]
1341-
impl std::error::Error for PatternSetInsertError {}
1340+
impl core::error::Error for PatternSetInsertError {}
13421341

13431342
#[cfg(feature = "alloc")]
13441343
impl core::fmt::Display for PatternSetInsertError {
@@ -1889,8 +1888,7 @@ pub enum MatchErrorKind {
18891888
},
18901889
}
18911890

1892-
#[cfg(feature = "std")]
1893-
impl std::error::Error for MatchError {}
1891+
impl core::error::Error for MatchError {}
18941892

18951893
impl core::fmt::Display for MatchError {
18961894
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {

regex-automata/src/util/wire.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ impl core::fmt::Display for SerializeError {
116116
}
117117
}
118118

119-
#[cfg(feature = "std")]
120-
impl std::error::Error for SerializeError {}
119+
impl core::error::Error for SerializeError {}
121120

122121
/// An error that occurs when deserializing an object defined in this crate.
123122
///
@@ -211,8 +210,7 @@ impl DeserializeError {
211210
}
212211
}
213212

214-
#[cfg(feature = "std")]
215-
impl std::error::Error for DeserializeError {}
213+
impl core::error::Error for DeserializeError {}
216214

217215
impl core::fmt::Display for DeserializeError {
218216
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {

regex-lite/src/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ impl Error {
1818
}
1919
}
2020

21-
#[cfg(feature = "std")]
22-
impl std::error::Error for Error {}
21+
impl core::error::Error for Error {}
2322

2423
impl core::fmt::Display for Error {
2524
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {

regex-syntax/src/ast/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ pub enum ErrorKind {
189189
UnsupportedLookAround,
190190
}
191191

192-
#[cfg(feature = "std")]
193-
impl std::error::Error for Error {}
192+
impl core::error::Error for Error {}
194193

195194
impl core::fmt::Display for Error {
196195
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {

regex-syntax/src/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ impl From<hir::Error> for Error {
3434
}
3535
}
3636

37-
#[cfg(feature = "std")]
38-
impl std::error::Error for Error {}
37+
impl core::error::Error for Error {}
3938

4039
impl core::fmt::Display for Error {
4140
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {

regex-syntax/src/hir/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ pub enum ErrorKind {
107107
UnicodeCaseUnavailable,
108108
}
109109

110-
#[cfg(feature = "std")]
111-
impl std::error::Error for Error {}
110+
impl core::error::Error for Error {}
112111

113112
impl core::fmt::Display for Error {
114113
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {

regex-syntax/src/unicode.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ pub enum Error {
3030
#[derive(Debug)]
3131
pub struct CaseFoldError(());
3232

33-
#[cfg(feature = "std")]
34-
impl std::error::Error for CaseFoldError {}
33+
impl core::error::Error for CaseFoldError {}
3534

3635
impl core::fmt::Display for CaseFoldError {
3736
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
@@ -51,8 +50,7 @@ impl core::fmt::Display for CaseFoldError {
5150
#[derive(Debug)]
5251
pub struct UnicodeWordError(());
5352

54-
#[cfg(feature = "std")]
55-
impl std::error::Error for UnicodeWordError {}
53+
impl core::error::Error for UnicodeWordError {}
5654

5755
impl core::fmt::Display for UnicodeWordError {
5856
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {

src/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ impl Error {
5353
}
5454
}
5555

56-
#[cfg(feature = "std")]
57-
impl std::error::Error for Error {
56+
impl core::error::Error for Error {
5857
// TODO: Remove this method entirely on the next breaking semver release.
5958
#[allow(deprecated)]
6059
fn description(&self) -> &str {

0 commit comments

Comments
 (0)