summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--integration_tests/tests/test_html5lib.rs2
-rw-r--r--src/error.rs9
-rw-r--r--tests/test_spans.rs2
3 files changed, 6 insertions, 7 deletions
diff --git a/integration_tests/tests/test_html5lib.rs b/integration_tests/tests/test_html5lib.rs
index 52df539..da3e983 100644
--- a/integration_tests/tests/test_html5lib.rs
+++ b/integration_tests/tests/test_html5lib.rs
@@ -122,7 +122,7 @@ fn run_test_inner<R: Reader>(
match token {
Token::Error { error, .. } => actual.errors.push(TestError {
- code: error.to_string(),
+ code: error.code().to_string(),
}),
Token::StartTag(tag) => actual.tokens.push(TestToken::StartTag {
name: tag.name,
diff --git a/src/error.rs b/src/error.rs
index 390b060..4ff9dfd 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -23,12 +23,11 @@ macro_rules! impl_error {
}
}
- impl std::fmt::Display for Error {
- /// Convert an enum variant back into the `kebap-case` error code as typically written
- /// in the WHATWG spec.
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ impl Error {
+ /// Returns the `kebap-case` error code as defined in the WHATWG spec.
+ pub fn code(&self) -> &'static str {
match *self {
- $( Self::$variant => $string.fmt(f), )*
+ $( Self::$variant => $string, )*
}
}
}
diff --git a/tests/test_spans.rs b/tests/test_spans.rs
index 70bcf6e..10735b2 100644
--- a/tests/test_spans.rs
+++ b/tests/test_spans.rs
@@ -202,7 +202,7 @@ fn annotate_errors(html: &'static str) -> String {
let mut labels = Vec::new();
for token in tokenizer(html) {
if let Token::Error { error, span } = token {
- labels.push((span, error.to_string()));
+ labels.push((span, error.code()));
}
}
annotate(html, labels)