Skip to content

Commit

Permalink
Auto merge of #396 - andrea-prearo:error-message-sub-expressions, r=B…
Browse files Browse the repository at this point in the history
…urntSushi

Remove sub-expressions from parsing error

This PR skips printing sub-expressions in the error message.

This should avoid situations where the error message contains an AST with unreadable characters, as shown [here](BurntSushi/ripgrep#395).

<img width="1030" alt="unreadable-chars" src="https://user-images.githubusercontent.com/12599697/29924193-02147d0c-8e11-11e7-8b36-a97b63f802b4.png">
  • Loading branch information
bors committed Oct 22, 2017
2 parents dc9e382 + ba5a3df commit 72cee88
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions regex-syntax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,9 +1574,8 @@ impl fmt::Display for ErrorKind {
write!(f, "Invalid character class range '{}-{}'. \
Character class ranges must start with the smaller \
character, but {} > {}", start, end, start, end),
InvalidClassEscape(ref e) =>
write!(f, "Invalid escape sequence in character \
class: '{}'.", e),
InvalidClassEscape(_) =>
write!(f, "Invalid escape sequence in character class."),
InvalidRepeatRange { min, max } =>
write!(f, "Invalid counted repetition range: {{{}, {}}}. \
Counted repetition ranges must start with the \
Expand All @@ -1588,9 +1587,8 @@ impl fmt::Display for ErrorKind {
write!(f, "Missing maximum in counted repetition operator."),
RepeaterExpectsExpr =>
write!(f, "Missing expression for repetition operator."),
RepeaterUnexpectedExpr(ref e) =>
write!(f, "Invalid application of repetition operator to: \
'{}'.", e),
RepeaterUnexpectedExpr(_) =>
write!(f, "Invalid application of repetition operator."),
UnclosedCaptureName(ref s) =>
write!(f, "Capture name group for '{}' is not closed. \
(Missing a '>'.)", s),
Expand Down

0 comments on commit 72cee88

Please sign in to comment.