Skip to content

Commit

Permalink
remove direct dependency between ParserError and subst::error.
Browse files Browse the repository at this point in the history
  • Loading branch information
cre4ture committed Jan 10, 2024
1 parent d76ee6b commit 06d603a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/uu/env/src/parse_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum ParseError {
},
ParsingOfVariableNameFailed {
pos: usize,

Check warning on line 29 in src/uu/env/src/parse_error.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/env/src/parse_error.rs#L29

Added line #L29 was not covered by tests
sub_err: subst::Error,
sub_err: String,
},
InternalError {
pos: usize,

Check warning on line 33 in src/uu/env/src/parse_error.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/env/src/parse_error.rs#L33

Added line #L33 was not covered by tests
Expand Down
2 changes: 1 addition & 1 deletion src/uu/env/src/split_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl<'a> SplitIterator<'a> {
Err(subst::Error::MissingVariableName(_)) => self.take_one(), // no variable name, take the $ char
Err(e) => Err(ParseError::ParsingOfVariableNameFailed {
pos: self.raw_parser.get_look_at_pos(),
sub_err: e,
sub_err: e.to_string(),
}),
}
}
Expand Down
21 changes: 14 additions & 7 deletions submodules/subst/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Module containing error details.
/// An error that can occur during variable substitution.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]

Check warning on line 4 in submodules/subst/src/error.rs

View check run for this annotation

Codecov / codecov/patch

submodules/subst/src/error.rs#L4

Added line #L4 was not covered by tests
#[cfg_attr(test, derive(Eq, PartialEq))]
pub enum Error {
/// The input string contains an invalid escape sequence.
InvalidEscapeSequence(InvalidEscapeSequence),

Check warning on line 8 in submodules/subst/src/error.rs

View check run for this annotation

Codecov / codecov/patch

submodules/subst/src/error.rs#L8

Added line #L8 was not covered by tests
Expand Down Expand Up @@ -138,7 +139,8 @@ impl std::fmt::Display for CharOrByte {
}

/// The input string contains an invalid escape sequence.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]

Check warning on line 142 in submodules/subst/src/error.rs

View check run for this annotation

Codecov / codecov/patch

submodules/subst/src/error.rs#L142

Added line #L142 was not covered by tests
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct InvalidEscapeSequence {
/// The byte offset within the input where the error occurs.
///
Expand Down Expand Up @@ -168,7 +170,8 @@ impl std::fmt::Display for InvalidEscapeSequence {
}

/// The input string contains a variable placeholder without a variable name (`"${}"`).
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]

Check warning on line 173 in submodules/subst/src/error.rs

View check run for this annotation

Codecov / codecov/patch

submodules/subst/src/error.rs#L173

Added line #L173 was not covered by tests
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct MissingVariableName {
/// The byte offset within the input where the error occurs.
///
Expand All @@ -189,7 +192,8 @@ impl std::fmt::Display for MissingVariableName {
}

/// The input string contains an unexpected character.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]

Check warning on line 195 in submodules/subst/src/error.rs

View check run for this annotation

Codecov / codecov/patch

submodules/subst/src/error.rs#L195

Added line #L195 was not covered by tests
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct UnexpectedCharacter {
/// The byte offset within the input where the error occurs.
///
Expand Down Expand Up @@ -221,7 +225,8 @@ impl std::fmt::Display for UnexpectedCharacter {
}

/// A struct to describe what was expected instead of the unexpected character.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]

Check warning on line 228 in submodules/subst/src/error.rs

View check run for this annotation

Codecov / codecov/patch

submodules/subst/src/error.rs#L228

Added line #L228 was not covered by tests
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct ExpectedCharacter {
/// A human readable message to describe what is expected.
pub(crate) message: &'static str,

Check warning on line 232 in submodules/subst/src/error.rs

View check run for this annotation

Codecov / codecov/patch

submodules/subst/src/error.rs#L232

Added line #L232 was not covered by tests
Expand All @@ -236,7 +241,8 @@ impl ExpectedCharacter {
}

/// The input string contains an unclosed variable placeholder.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]

Check warning on line 244 in submodules/subst/src/error.rs

View check run for this annotation

Codecov / codecov/patch

submodules/subst/src/error.rs#L244

Added line #L244 was not covered by tests
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct MissingClosingBrace {
/// The byte offset within the input where the error occurs.
///
Expand All @@ -254,7 +260,8 @@ impl std::fmt::Display for MissingClosingBrace {
}

/// The input string contains a placeholder for a variable that is not in the variable map.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone)]

Check warning on line 263 in submodules/subst/src/error.rs

View check run for this annotation

Codecov / codecov/patch

submodules/subst/src/error.rs#L263

Added line #L263 was not covered by tests
#[cfg_attr(test, derive(Eq, PartialEq))]
pub struct NoSuchVariable {
/// The byte offset within the input where the error occurs.
///
Expand Down

0 comments on commit 06d603a

Please sign in to comment.